ritenn / implementator
Binding automatically interfaces to implementation and also helps creating custom class files e.g. Service or Repository.
Requires
- php: >=7.0
- laravel/framework: 7.* || 8.*
Requires (Dev)
- orchestra/testbench: 5.*
- phpunit/phpunit: ^8.5 || ^9.0
This package is auto-updated.
Last update: 2024-10-13 04:10:09 UTC
README
This package adds additional 3 artisan commands that will speed up your development. You can quickly create contract/interface and implement it to your service or repository layer just like with any other artisan commands e.g. make:model
etc. Additionally, it automatically binds interface to implementation by base file name, which means that you don't have to waste time to do it manually.
Make your code clean and readable!
Installation
Requires PHP >=7.0 and Laravel 7.x
composer require ritenn/implementator
Publishing config
That will copy 'implementator' config to your app config directory
php artisan vendor:publish --provider="Ritenn\Implementator\ImplementatorServiceProvider" --force
Available commands and options
php artisan make:service *baseName
- creates contract and implementation for your service layerphp artisan make:repository *baseName
- creates contract and implementation for your repository- You can also use option
--without-contract
, if you want to create just layer without contract implementation - Finally, you can create contract without implementation using
php artisan make:contract *baseName
. However, if contracts categorization is enabled in your config you must also specify layer name e.g.--layer=Services
*baseName - e.g. TestService, base name is 'Test', UserRepository > User, CartContract > Cart
Configuration
- You can change it to 'Interfaces' if you wish, that will affect folders/files/class names
'terminology' => 'Contracts'
- If enabled, commands will create additional subfolders for your contracts
'contracts_categories' => true
- If enabled, bindings will be loaded from cache in production
'cache' => true
- You can add exceptions for auto-bindings, if your class requires additional parameters that won't be auto resolved by laravel.
'binding_exceptions' => array()
e.g.
binding_exceptions' => array(['App\Contracts\Services\TestContract' => 'App\Services\TestService'], [... => ...], ...)