To get started with Laravel Service Command, simply require the package via Composer:
composer require lozemc/laravel-services
Next, add the following line to the $commands array in your /app/Console/Kernel.php
file:
protected $commands = [
// ...
\App\Console\Commands\ServiceMakeCommand::class,
];
If the protected $commands array does not exist, you will need to add it.
Then add the following line to the returned array in /bootstrap/providers.php
:
return [
// ...
Lozemc\Services\Providers\MakeServiceProvider::class,
];
Once installed and configured, you can use the artisan command to create a new service:
php artisan make:service PostService
This will generate a new service class named PostService
in the App\Services
namespace. You can then implement
your business logic within this service class.