rez1pro / service-create-command
Laravel Service Create Command
Installs: 1 543
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/rez1pro/service-create-command
README
Overview
The Service Pattern is a design pattern that encapsulates business logic into dedicated service classes. This pattern helps maintain separation of concerns and improves code organization by isolating business operations from other layers of the application.
Purpose
- Separate business logic from controllers and models
- Promote code reusability
- Make testing easier by isolating business operations
- Reduce controller complexity
- Improve maintainability
Structure
- Service classes are typically located in the
app/Servicesdirectory. - Each service class is named after the feature it encapsulates, using camelCase notation.
- Services are responsible for handling business logic related to a specific feature or module.
- Services can be used by controllers or other components that need to perform specific operations.
Usage
- Create a new service class in the
app/Servicesdirectory. - Implement the business logic in the service class.
- Use the service class in controllers or other components that need to perform specific operations.
Installation
- Run
composer require rez1pro/service-create-command - Run
php artisan make:service <service-name>to create a new service class.
Register Service Provider
in bootstrap/providers.php
Rez1pro\ServicePattern\ServicePatternServiceProvider::class,
Example
- Run
php artisan make:service SendMessageServiceto create a new service class.