This tool might not be as well known as the previous mentioned ones, but it is the only tool, which controls (at least part of) the application architecture. The principle of the tool of really simple – you setup the tool using short YAML file consisting of a few parts: file (class) groups, path where to look for the classes and finally – the dependencies rules.
The installation ca be done easily using composer as usual – just one note – use the „shim“ repository to avoid dependencies conflicts:
composer require --dev sensiolabs-de/deptrac-shim
Then the configuration itself… Simple example could look like this:
paths: - ./src layers: - name: Controller collectors: - type: className regex: .*Controller.php - name: Facade collectors: - type: className regex: .*Facade.php - name: Repository collectors: - type: className regex: .*Repository.php ruleset: Controller: - Facade Facade: - Repository Repository:
The example above shows the configuration which will make sure no one will ever inject the repository directly into the container.
There are also other ways to setup the rules and the file patterns, so which rules use and how to setup depends only on your creativity. All required information can be find on the official documentation: https://github.com/sensiolabs-de/deptrac
Describing all the benefits, setup and usage of the PHPUnit is far beyond the scope of this „overview“ article, but I just couldn’t leave it out.) I’ve got another article in preparation, but it might take some time to describe all the information i want to share.
Get get at least a small insight into PHPUnit usage, follow the official documentation, which briefly describes, how to setup the „MVP“ of the tests. https://phpunit.de/getting-started/phpunit-9.html
All described tools I find really handy and use them on daily basis, but they are all king of useless, when not properly and strictly used in CI/CD (another article focused on CircleCI and Gitlab pipelines also coming soon)
Hopefully you have found some inspiration to begin with, good luck!