nordcoders / laravel-service-maker
Generate services and contracts in Laravel with the artisan command
Installs: 1 161
Dependents: 0
Suggesters: 0
Security: 0
Stars: 26
Watchers: 2
Forks: 6
Open Issues: 3
Requires
- php: ^8.1
- illuminate/contracts: ^9.0
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-10-09 07:37:55 UTC
README
What does it do?
This package adds a new php artisan make:service {name} {--N|noContract}
command. It will create a service file and its contract (interface) for saving time while working with Laravel Framework and benefit from the Service Pattern.
Installation
You can install the package via composer:
composer require nordcoders/laravel-service-maker --dev
How does it work?
After installation, the command php artisan make:service {name} {--N|noContract}
will be available.
Create services files
For example, the command php artisan make:service createUser
will generate a service file called CreateUserService.php
located in app/Services/CreateUser
.
It will also generate an interface (contract) called CreateUserContract.php
located in app/Services/Contracts
.
Create services for models
Adding a --service
or -S
option is now available when creating a model.
For example, the command php artisan make:model Book --service
or php artisan make:model Book -S
will generate a model with service too.
The command php artisan make:model Book --all
or php artisan make:model Book -a
will now generate a model, migration, factory, seeder, policy, controller, form requests and service.
Contracts
Adding a --noContract
or -N
option will prevent the commands from implementing any contract and will not create any contract file.
If you never need any contracts. Publish the config file and then turn the with_interface value to false in the config file.
Configuration file
You can publish the config file with:
php artisan vendor:publish --tag="service-maker-config"
This is the content of the published config file:
return [ 'with_interface' => true, ];
Credits
License
The MIT License (MIT). Please see License File for more information.