Download the PHP package drewlabs/g-cli without Composer
On this page you can find all versions of the php package drewlabs/g-cli. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download drewlabs/g-cli
More information about drewlabs/g-cli
Files in drewlabs/g-cli
Package g-cli
Short Description Generates classes, services, models and controller's components or entire project source code from databse structure
License MIT
Informations about the package g-cli
GCli
This project uses the code generator package to create components like controllers, services, models etc for laravel projects...
Usage
Programming API
This section present you with PHP classes API for creating controllers, Services, Model, ViewModel and Data Transfert Object
The Controller Builder
This package provide you with a controller class builder that can be used to build a resource controller, an invokable controller or a pre-made CRUD controller.
Service class builder
A service is like a delegate that handle controller action and has access to the database model.
You can create a service that provides empty implementation or is pre-filled with CRUD operations.
View Model class builder
A view model is a class that wrap arround user provided values, validation rules and if possible a reference to the authenticated user.
Model class builder
A database model is like en entity manager class that interact with database on your behalf. They packahe provides an implementation of the Eloquent ORM model.
This implementation use the drewlabs/database package for the builder and it suppose that package is install as dependency. You are free to provide an implementation of your on builder.
Laravel Commands interfaces
The package offers some laravel framework commands for easily creating component from your terminal application. Those commands are:
drewlabs:mvc:create command
This command allow devolpper to generate an entire api stack from database tables, with a pre-defined structure. The generated output is configurable using artisan command interface input:
- Creating mvc component along with controllers and routes
Disabling caching
By default the command use caching to optimize the task when generating more than once required components. using the command below, the command will ignore the cache and re-generate previously generated files:
Removing schema prefix
In some application, databases are prefixed using schema name. Generated code will mostly add the schema prefix to classes and interfaces. To prevent such output, developper can use --schema
option to allow the tell the command to trim the schema part from generated classes:
Adding middleware
Sometimes developpers might want to group generated routes in a given middleware. The command interface provide an option to specify the middleware to use when grouping generated route using:
Table filters
The command interface also support an --only
option wich allow developpers to specify the list of table to include when generating code:
Warning The --only
option is in an experimental status, and as it can rewrite your routing file removing previously generated routes.
Setting route file name
By default the routing file name used by the command is web.php
located in the /routes directory of the laravel project. To override the default:
The command above use or create a file in the project /routes directory for routing.
Model relations
drewlabs:mvc:create
provides a flag for generating relation method definition while generating model class definition. Using --relations
flag, developpers can generate model with corresponding relations
.
FAQ How can model relation methods can be customized ?
The command support argument for model relation customization. using --manytomany
, --toones
, --manythroughs
, --onethroughs
, developpers are able to specify relation that are many to many
, one to one
, many through
and one through
relation respectively.
The syntax for various customization are:
manytomany
source_table->pivot_table->destination_table:method
Note [method]
part of the syntax can be omitted and will be generated by the command.
toones
source_table->destination_table:method
Note [method]
part of the syntax can be omitted and will be generated by the command.
onethroughs
&manythroughs
source_table->pivot_table->destination_table:method
Note [method]
part of the syntax can be omitted and will be generated by the command.
Policy & Guard
From version 2.9
, drewlabs:mvc:create
command suport flag for adding policy guard definition to your project with default to allowing every controller action using authorize
method. To generate policy classes use the --policies
flag when running command.
Note A service provider class [\App\Providers\PoliciesServiceProvider::class]
class is generated at the end of the command output. Please add it to let laravel know how to guard your model classes using generated policies.
Note
To preview the list of available options, please use the php artisan drewlabs:mvc:create --help
Create a database model
Create a php class
Note Use php artisan drewlabs:mvc:make:class --help
command view the list of option available
Create a data transfert object
Note Use php artisan drewlabs:mvc:make:dto --help
command view the list of option available
Create a MVC service
Note Use php artisan drewlabs:mvc:make:service --help
command view the list of option available
Create a MVC view model
Note Use php artisan drewlabs:mvc:make:viewmodel --help
command view the list of option available
Create a MVC controller
Note Use php artisan drewlabs:mvc:make:controller --help
command view the list of option available
All versions of g-cli with dependencies
drewlabs/code-generator Version ^0.2.4
drewlabs/core-helpers Version ^0.2.2|^0.3
drewlabs/htr Version ^0.2.0