Download the PHP package ins0mniac/service-generator without Composer
On this page you can find all versions of the php package ins0mniac/service-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ins0mniac/service-generator
More information about ins0mniac/service-generator
Files in ins0mniac/service-generator
Package service-generator
Short Description The package provide commands for generating services and interfaces and registering them in the dependency container
License MIT
Informations about the package service-generator
Laravel Service generator for Laravel applications
Introduction
Service generator provides commands to create services, interfaces and providers and register the dependencies in the dependency container.
With this package, you can generate new files (services, interfaces and providers) only with "artisan" command just as controllers creation. It is not necessary to list the provider in app.php file. The process of listing providers in app.php and registering the dependencies in the providers is automated.
The list of the available commands are shown below:
Features
- Laravel >= v8.0 are supported;
- Easy setup, no additional configuration;
- Easy to use;
- It's made only to facilitate the work of developers;
- Free and always be free.
Official Documentation
- Installation;
- Commands:
- Service creation:
- Plain service;
- Service with implementation;
- Interface creation;
- Interface only;
- Generate interface and implement it from service;
- Provider creation;
- Provider only;
- Register dependency in new or existing provider;
- Service creation:
- Examples of generated files;
- Coming soon;
- License.
Installation
You can install this package via Composer by running this command:
NOTE : The package will automatically register itself.
Commands
For services creating:
Plain service
You can generate plain service (php file) with :
If you don't specify the name of the service, Laravel will ask you to type it.
With this command, Laravel will generate new file with all the necessary attributes as namespace, class name, etc. The file will be generated in Services/* directory (based of the name of the service), so if you type service name as Users/User
, the service file will be located in Services/Users
with name of UserService
.
Service with implementation
You can generate service which implements interface:
class NameOfTheService impements NameOfTheInterface
or just
If you don't specify name of the service and/or interface, Laravel will ask you for them.
After you type the interface name, Laravel will ask you if you want to register dependency in the container. If you want to register it, just type y
and enter the name of the Provider (if provider didn't exists, the command will create new one and publish it in app.php). After entering the provider name, you should specify the type of the registering - bind or singleton.
NOTE : This command will create new service file, so if you shouldn't type name of the existing file!
In the end of the generation process you will have:
- New Service class (new file);
- Service class that implements new or existing Interface;
- Registered dependency in new or existing Provider;
For interfaces creating:
Interface only
You can generate only interface (php file) with :
If you don't specify the name of the interface, Laravel will ask you to type it.
Generate interface and implement it from new or existing service
You can generate interface and implement it:
class NameOfTheService impements NameOfTheInterface
or just
If you don't specify name of the interface and/or service, Laravel will ask you for them.
After you type the interface name, Laravel will ask you if you want to register dependency in the container. If you want to register it, just type y
and enter the name of the Provider (if provider didn't exists, the command will create new one and publish it in app.php). After entering the provider name, you should specify the type of the registering - bind or singleton.
In the end of the generation process you will have:
- Service class that implements new or existing Interface;
- Registered dependency in new or existing Provider;
For provider creating:
Provider only
You can generate only provider (php file) with :
If you don't specify the name of the provider, Laravel will ask you to type it.
Generate or get existing provider and register dependency in it
You can generate or get existing provider:
or just
If you don't specify name, Laravel will ask you for them.
After you type the provider name, Laravel will ask you for the names of service and interface and the type of the registering - bind or singleton.
In the end of the generation process you will have:
- Service class that implements new or existing Interface;
- Registered dependency in new or existing Provider;
Examples of generated files
- Plain service;
- Services with implementation;
- Interface;
- Provider;
- Changes in app.php;
Coming soon
The next stage will be adding --resource option to create:service and create:interface commands. This will allow you to generate files with resource methods - getAll(), findByKey(Model $model), etc.
License
Laravel Service Generator is open-sourced software licensed under the MIT license.