mattyeend / laravel-model-service
Extends Laravel make:model to also create a service class when using -S flag or --service option.
Fund package maintenance!
MattYeend
MatthewYeend
Buy Me A Coffee
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/mattyeend/laravel-model-service
Requires
- php: >=8.1
- illuminate/console: ^10.0|^11.0|^12.0
- illuminate/filesystem: ^10.0|^11.0|^12.0
- illuminate/support: ^10.0|^11.0|^12.0
README
Extends Laravel's make:model Artisan command to also generate a Service class in app/Services when using the -s (or --service) flag.
Features
- Works with Laravel 10, 11, and 12
- Fully PSR-4 compliant
- Generates service alongside model, migration, and controller
- Seamlessly integrates with all existing
make:modeloptions
Installation
composer require mattyeend/laravel-model-service
Laravel will auto-discover the service provider.
Usage
php artisan make:model Post -mcrS # -> Creates Post model and PostService php artisan make:model Post --service # -> Creates PostService php artisan make:model Post -a # -> Creates Post model, migration, controller, factory, seeder, policy, # and now also Postervice
This will create:
app/
Models/
Post.php
Services/
PostService.php
Http/
Controllers/
PostController.php
database/
migrations/
2025_08_15_000000_create_posts_table.php
Flags
-m— Create migration-c— Create controller-r— Resource controller-S/--service— Create service
Customizing the Service Stub
You can publish the stub to modify the generated service file:
php artisan vendor:publish --tag=stubs
This will place stubs/service.stub in your project root.
Modify it to fit your coding standards.
License
This package is licensed under the MIT License.
Contributing
Feel free to fork the repository and submit pull requests for improvements or new features!