layman / laravel-architect
Laravel package for generating controllers, requests, models, and repositories from configuration.
Requires
- php: ^8.3
- illuminate/console: ^11.0|^12.0|^13.0
- illuminate/filesystem: ^11.0|^12.0|^13.0
- illuminate/support: ^11.0|^12.0|^13.0
- spatie/laravel-route-attributes: ^1.28
README
Generate Laravel controllers, form requests, models, and repositories from config/architect.php.
Generated controllers use spatie/laravel-route-attributes by default.
Installation
Install the package in a Laravel application:
composer require layman/laravel-architect
Laravel package discovery registers Layman\LaravelArchitect\ArchitectServiceProvider automatically.
Publishing
Publish the config file:
php artisan vendor:publish --tag=architect-config
Publish the default stubs if you want to customize generated code:
php artisan vendor:publish --tag=architect-stubs
By default, published stubs are copied to artisan-generator-stubs.
Usage
Generate all configured artifacts:
php artisan architect:make User
Generate selected artifact types:
php artisan architect:make User --only=controller --only=request
Overwrite existing generated files:
php artisan architect:make User --force
Nested module names are supported:
php artisan architect:make Admin/User
Use {{modulePath}} in config/architect.php paths if nested module names should also affect output namespaces.
Configuration
config/architect.php controls namespaces and generated files:
'namespace' => [ 'controller' => 'App\Http\Controllers', 'request' => 'App\Http\Requests', 'repository' => 'App\Repositories', 'model' => 'App\Models', ], 'template' => [ 'files' => [ 'controller' => [ 'path' => 'Backend', 'name' => '{{module}}Controller', 'stub' => 'controller.stub', ], ], ],
Supported placeholders include {{module}}, {{module_snake}}, {{module_kebab}}, {{module_camel}}, {{module_plural}}, {{module_plural_snake}}, {{table}}, and {{variable}}.
The default controller stub adds #[Prefix('{{module_snake}}')], uses #[Post(...)] for every action, and sets #[Defaults('description', '')].