Monthly Downloads: 36,201
Programming language: PHP
License: MIT License
Latest version: v0.10.0

PHP Architecture Tester alternatives and similar libraries

Based on the "Static Analysis" category.
Alternatively, view PHP Architecture Tester alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of PHP Architecture Tester or a related project?

Add another 'Static Analysis' Library


Easy to use architecture testing tool for PHP

โ„น๏ธ PHPat has been converted into a PHPStan extension. Read the [UPGRADE notes](doc/UPGRADE-0.10.md)! The standalone version (v0.9) will still be available and receive critical bugfixes if needed.

Introduction ๐Ÿ“œ

PHP Architecture Tester is a static analysis tool to verify architectural requirements.

It provides a natural language abstraction to define your own architectural rules and test them against your software.

Check out the section [WHAT TO TEST](doc/WHAT_TO_TEST.md) to see some examples of typical use cases.

Installation ๐Ÿ’ฝ

Require PHPat with Composer:

composer require --dev phpat/phpat

If you also install phpstan/extension-installer then you're all set!

Manual installation

If you don't want to use phpstan/extension-installer, enable the extension in your PHPStan configuration:

# phpstan.neon
    - vendor/phpat/phpat/extension.neon

Configuration ๐Ÿ”ง

You will need to register your test classes in your PHPStan configuration:

# phpstan.neon
        class: Tests\Architecture\MyFirstTest
            - phpat.test
        class: Tests\Architecture\MySecondTest
            - phpat.test

โš ๏ธ Your architecture tests folder should be included in the PHPStan analysed paths. See [PHPat's own PHPat configuration](ci/phpstan-phpat.neon) as an example.

You can also configure some PHPat options, for instance:

# phpstan.neon
        ignore_doc_comments: true

Complete list of options

Name Description Default
ignore_doc_comments Ignore relations on Doc Comments false

Test definition ๐Ÿ““

There are different [Selectors](doc/SELECTORS.md) to choose which classes will intervene in a rule and a wide range of [Assertions](doc/ASSERTIONS.md).

This could be a test with a couple of rules:


use PHPat\Selector\Selector;
use PHPat\Test\Builder\Rule;
use PHPat\Test\PHPat;
use App\Domain\SuperForbiddenClass;

class MyFirstTest
    public function test_domain_does_not_depend_on_other_layers(): Rule
        return PHPat::rule()
                Selector::classname('/^SomeVendor\\.*\\ForbiddenSubfolder\\.*/', true)

Usage ๐Ÿš€

Run PHPStan as usual:

php vendor/bin/phpstan analyse -c phpstan.neon

โš  Launching early stage releases (0.x.x) could break the API according to Semantic Versioning 2.0. We are using minor for breaking changes. This will change with the release of the stable 1.0.0 version.

PHP Architecture Tester is open source, contributions are welcome. Please have a look to the [Contribution docs](.github/CONTRIBUTING.md).