Download the PHP package josanangel/service-repository-manager without Composer
On this page you can find all versions of the php package josanangel/service-repository-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download josanangel/service-repository-manager
More information about josanangel/service-repository-manager
Files in josanangel/service-repository-manager
Package service-repository-manager
Short Description Service Repository Pattern Creator
License MIT
Informations about the package service-repository-manager
Laravel Service-Repository Generator
This package provides artisan commands to easily generate Services and Repositories, following the Service-Repository Pattern, which are not natively supported in Laravel. It helps developers maintain a clean and scalable code structure.
The code is designed so that any developer can build upon it, as it follows best practices and clean code principles.
Features
- Generate repository and service classes with a single command.
- Adheres to the Service-Repository Pattern.
- Automatically binds repositories to interfaces in the Laravel service container.
- Customizable templates for your own conventions.
Requirements
- PHP 8.0 - 8.4
- Composer
- nette/php-generator >= 4.1
Packagist Page
https://packagist.org/packages/josanangel/service-repository-manager
Installation
Install the package via Composer:
After install
Add the following service provider to your bootstrap/providers.php
file:
``
Configuration
Example .env
`
Publish configuration file
`
Laravel module (Optional)
If your project follows a module structure such as https://nwidart.com/laravel-modules/v6/introduction
You need to change SRM_MODULES
to true and set a repository and service namespace which contains
the {node_modules}
keyword to replace in execution time when commands are called.
Then the commands will need --module=
option to specify where file should be located.
Example .env using module:
Commands examples using module:
Execute composer dump-autoload after that:
Command parameter details
Command | Parameter | Type | Description | Required |
---|---|---|---|---|
php artisan make:repository |
name |
Argument | Name of the repository you want to create. | Yes |
--module |
Option | Specifies where the file(s) will be generated. | No | |
--crud |
Option | Specifies if the repository should include predefined CRUD functions. | No | |
php artisan make:service |
name |
Argument | Name of the service you want to create. | Yes |
--module |
Option | Specifies where the file(s) will be generated. | No | |
--repositories |
Option | Indicates possible repositories to declare as injected dependencies in the main service file. | No | |
--services |
Option | Indicates possible services to declare as injected dependencies in the main service file. | No | |
--repositories-crud |
Option | Indicates repositories to declare as injected dependencies, including predefined CRUD functions. | No |
Examples
Create a UserRepository file
Content
``
Create a UserRepository file with CRUD methods
Content
``
Create a UserService file
Output
``
Create a UserService file with injected dependencies
UserService + [ injected ] AuthService
Output
UserService + [ injected ] AuthService + [ injected ] MapService + [ injected ] UserRepository
Output
UserService + [ injected ] UserRepository with CRUD methods
``
``