This repository is a demo of Explicit Architecture, using the Symfony Demo Application.
The “Symfony Demo Application” is a reference application created to show how
to develop Symfony applications following the recommended best practices.
This repository is a demo of Explicit Architecture, using the Symfony Demo Application.
There is code in this project that not used and therefore it would be removed in a real project, nevertheless
it was included here as examples.
I explained Explicit Architecture in one of my blog posts, as a result of my understanding of several architectural
ideas such as (but not limited to) EBI Architecture, DDD, Ports & Adapters Architecture,
Onion Architecture and Clean Architecture.
Since the code organization, its structure, is quite explicit we can easily have an architectural integrity test
suite to make sure we are not breaking the architecture.
This project architectural integrity test suite consists of three tests, which are executed using deptrac.
Deptrac can also generate some nice graphs with the dependencies tree, which makes it great as a documentation artifact.
Layer dependencies integrity
This tests the code layers dependency integrity, making sure the dependencies always goes inwards,
when matched to the layers in the Explicit Architecture diagram on top.
Component dependencies integrity
This test makes sure that the components are decoupled between them.
Class type dependencies integrity
This test goes to a class level dependency integrity check, specially useful for classes in the same layer and component.
For example, the application services, query objects and repositories all belong to the Application Layer,
and they all exist within each component. However, there are rules that must be followed:
You need to have docker installed in your host OS.
Execute the following commands to prepare the project locally:
$ composer install
$ make box-build-prd
$ make dep_analyzer-install
Execute this command to run the tests suite:
$ make test
Execute this command to run the app in dev mode:
$ make up
or this command to run the app in production mode:
$ make up-prd
Access the application in your browser at http://localhost:8000.
You can also test the error pages at http://localhost:8000/index.php/_error/{statusCode}.{format}
,
ie. http://localhost:8000/index.php/_error/400.html.
To see all commands available run:
$ make
To be able to run the architecture integrity tests, you first need to install deptrac:
$ make dep_analyzer-install
Execute this command to run tests:
$ make test
Or this command to run tests and get the coverage:
$ make test_cov
Integration with PHPStorm is straight forward.
Configure the servers so we can debug a request made from the browser:
Configure the CLI so we can run the tests:
Configure the test run itself:
The dev container has xDebug installed and you can use it out of the box, provided that you have your IDE configured
appropriately.
Check the screenshots in the docs/IDE/PHP_Storm/
folder, to check how to configure PHP Storm to work with xDebug, as
it is set up in the dev docker image.
To run the tests with xDebug enabled, you need to enable it in container/tst/xdebug.ini:1
prior to running the tests.