pestphp/pest-plugin-arch
Pest Plugin Arch adds architecture testing to Pest, letting you enforce project boundaries and design rules with simple tests. Ideal for keeping Laravel/PHP codebases consistent and preventing unwanted dependencies.
Install the plugin via Composer:
composer require pestphp/pest-plugin-arch --dev
Then run php artisan test (Laravel) or pest directly to discover architecture rules defined in tests/Arch.php. The primary entrypoint is tests/Arch.php, where developers declare architectural constraints (e.g., classes()->expect()->toHaveMethod('handle'), classes()->thatExtend(Widget::class)). Begin with simple assertions like namespaces()->expect()->toBeUsedIn('App\Models') to enforce命名 conventions or structural boundaries.
App\Services, App\Actions, App\Jobs) using directories() or namespaces()..expect() with methods like toHaveMethod(), not()->toHaveMethod(), shouldImplement(), or shouldExtend() for expressive contracts.->which() with ->and(), ->or(), ->not() to compose complex filters (e.g., classes()->in('App/Console')->which()->areNotAbstract()).pest --group=arch to your CI pipeline to fail builds when architecture drifts occur. Integrate with pest/pest-plugin-pest or pestphp/pest-plugin-laravel for unified test suites.tests/Arch/*) and run selectively.namespaces() resolves based on Composer autoload mappings, while directories() inspects filesystem paths—ensure your composer.json is updated to avoid mismatches.pest tests/Arch.php --debug to see detailed inspection logs; inspect which() filters and expect() chain errors carefully—misapplied filters are the most common cause of false positives. Pest\Plugins\Arch\Rule or register custom expectations in tests/Arch.php using the underlying ta-tikoma/phpunit-architecture-test API.How can I help you explore Laravel packages today?