Extend your generator commands to scaffold common domain patterns like Actions, Custom Query Builders, and Collections directly via Artisan.
Pushing domain logic into single-purpose Action classes or custom Eloquent Query Builders keeps controllers and models lean.
Using mrpunyapal/laravel-extended-commands, you can scaffold these patterns directly from the CLI.
Installation & CLI Usage
composer require --dev mrpunyapal/laravel-extended-commands
# Scaffold a custom Eloquent Query Builder
php artisan make:builder UserBuilder
# Scaffold a single-action class
php artisan make:action CreateOrderAction
# Scaffold a custom Eloquent Collection
php artisan make:collection OrderCollection
Why Use Dedicated Generators
- Custom Builders: Encapsulates complex query scopes into a dedicated builder class (
app/Builders/UserBuilder.php) instead of bloating the Model. - Action Classes: Generates invokable, single-responsibility classes (
app/Actions/CreateOrderAction.php) for business transactions. - Team Consistency: Enforces predictable directory structures and namespaces across the entire development team.
Related Tips
View all tips →Customize Artisan Code Generators with stub:publish
Publish and customize Artisan generator stubs using php artisan stub:publish to enforce custom code conventions across your team.
Protect Custom Artisan Commands from AI Agents with Prohibitable
Use Laravel's Prohibitable trait on custom Artisan commands to selectively block AI agents from running destructive domain operations.