Skip to content

Create a new Service file

MisterDebug edited this page Aug 12, 2023 · 1 revision

Create a new Service file

With the command make:service, you can create a Service file.

Example in real life, you want to create a PostService file

Service generator command :

Let's create your Service : php artisan make:Service PostService

That's it :)

By default, your file will be created in app/Services directory and App\Services namespace

Config custom namespace and path :

You can customize namespace and path in crudgen.php, add this array and fill it with your data :

 'paths' => [ 'service' => [ 'path' => app_path('Services'), 'namespace' => 'App\Services' ] ] 

Remove

You can delete service created by the make:service command

php artisan rm:service nameService --force

php artisan rm:service PostService --force (in our example)

--force (optional) can delete file without confirmation

Clone this wiki locally