joelbutcher/laravel-services

A simple, extensible implementation for crafting easy-to-use service classes in Laravel.

v1.0.1 2022-12-09 15:36 UTC

This package is auto-updated.

Last update: 2024-04-09 18:26:19 UTC


README

This package provide an intelligent and easy-to-use method for creating and defining Service Layer classes in your application.

Total Downloads Latest Stable Version License

Install

Require the package via composer.

composer require joelbutcher/laravel-services

Laravel-Services comes with package discovery and Laravel will register the service provider automatically. However, if you wish to explicitly register the service manually, you may do so by adding it to you config/app.php file.

'providers' => [
    // ...
    \JoelButcher\LaravelServices\ServiceProvider::class,
],

Usage

To create a new service class for your application you may call the make:service artisan command:

php artisan make:service FooService

This will generate a new FooService.php file inside the Services folder of your projects root namespace directory.

Identifier

Service classes require an identifier value. This value is used to determine the config values to fetch from Laravel's services config repository (config/services.php).

You may specify the identifier when running make:service by appending --idenfifier=<your-service-identifier> to the end. If not provided, the package will attempt to derive the identifier from the provided service name by using the snake_case version of the name in lower case:

Name Resolved
Foo foo
FooBar foo_bar
MyService my_service

Contributing

Thank you for considering contributing! Please adhere to GitHub contribution guidelines and provide as much context / information as possible with your pull request.

License

This package is open-sourced software licensed under the MIT license.