structuraphp / structura-laravel
Laravel extension for Structura - Architectural testing stubs for Laravel applications
dev-main
2026-05-24 14:48 UTC
Requires
- php: ^8.2|^8.3|^8.4|^8.5
- illuminate/config: ^11.0|^12.0|^13.0
- illuminate/console: ^11.0|^12.0|^13.0
- illuminate/support: ^11.0|^12.0|^13.0
- structuraphp/structura: ^0.7
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.94
- orchestra/testbench: ^11.0
- phpstan/phpstan: ^2.1
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^11.5|^12.5|^13.0
- rector/rector: ^2.3
- shipmonk/composer-dependency-analyser: ^1.8
This package is not auto-updated.
Last update: 2026-05-24 18:00:31 UTC
README
Laravel extension for Structura — Install pre-configured architecture test stubs for your Laravel application.
Installation
composer require --dev structuraphp/structura-laravel
The service provider is auto-discovered by Laravel.
Usage
Initialize architecture tests
php artisan structura:init
This command will:
- Create the
structura.phpconfig file at the root of your project (if it doesn't exist) - Prompt a multi-select to choose which architecture test stubs to install
- Generate the selected test files in
tests/Architecture/
Run Structura commands
The structura command is a pass-through to the native StructuraPHP CLI:
# Run architecture analysis (default) php artisan structura # Explicit analyze php artisan structura analyze # With options php artisan structura analyze --test-suite=laravel --stop-on-failure # Other commands php artisan structura init php artisan structura make:test
Configuration
Publish the config file to customize paths and namespaces:
php artisan vendor:publish --tag=structura-config
This creates config/structura.php:
return [ // Output directory for generated test files 'output_dir' => 'tests/Architecture', // Namespace for generated test classes 'output_namespace' => 'Tests\\Architecture', // Source paths per category 'paths' => [ 'controller' => 'app/Http/Controllers', 'dto' => 'app/DataTransferObjects', 'event' => 'app/Events', 'factory' => 'database/factories', 'form_request' => 'app/Http/Requests', 'job' => 'app/Jobs', 'listener' => 'app/Listeners', 'mail' => 'app/Mail', 'middleware' => 'app/Http/Middleware', 'model' => 'app/Models', 'notification' => 'app/Notifications', 'policy' => 'app/Policies', 'route' => 'routes', 'service' => 'app/Services', ], ];
Requirements
| Dependency | Version |
|---|---|
| PHP | >= 8.2 |
| Laravel | 11.x / 12.x / 13.x |
| Structura | >= 0.7 |
