1. Go to this page and download the library: Download drewlabs/g-cli library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
drewlabs / g-cli example snippets
// ...
use function Drewlabs\GCli\Proxy\ComponentsScriptWriter;
use function Drewlabs\GCli\Proxy\MVCControllerBuilder;
// ...
// This code creates an invokable controller
ComponentsScriptWriter(__DIR__ . '/examples/src')->write(
(MVCControllerBuilder())
->bindServiceClass(
"App\\Services\\PersonsService"
)
->asInvokableController()
->build()
);
// This code creates a resource controller and bind it to a model
// If conroller name is not provided, it's generated from the model name
ComponentsScriptWriter(__DIR__ . '/examples/src/')->write(
(MVCControllerBuilder('PostsController', '\\App\\Http\\Controllers\\Common'))
->bindServiceClass(
"App\\Services\\PersonsService"
)
->build()
)
// ...
use function Drewlabs\GCli\Proxy\ComponentsScriptWriter;
use function Drewlabs\GCli\Proxy\MVCServiceBuilder;
// ...
// Creating a prefilled service with name derived from a model class name
ComponentsScriptWriter(__DIR__ . '/examples/src/')->write(
(MVCServiceBuilder())
->bindModel(
"App\\Models\\Human"
)
->asCRUDService()
->build()
)
// Creates a simple service with only a handle method
ComponentsScriptWriter(__DIR__ . '/examples/src/')->write(
(MVCServiceBuilder())
->bindModel(
"App\\Models\\Person"
)
->build()
)
// ...
use function Drewlabs\GCli\Proxy\ComponentsScriptWriter;
use function Drewlabs\GCli\Proxy\ViewModelBuilder;
// ...
// Creating a fully complete view model
ComponentsScriptWriter(__DIR__ . '/examples/src/')->write(
(ViewModelBuilder())
->bindModel(
"App\\Models\\Person"
)
->addInputsTraits()
->addFileInputTraits()
->addAuthenticatableTraits()
->setRules([
'firstname' => '50'
])
->build()
)
// ....
use function Drewlabs\GCli\Proxy\ComponentsScriptWriter;
use function Drewlabs\GCli\Proxy\EloquentORMModelBuilder;
use function Drewlabs\GCli\Proxy\ORMColumnDefinition;
use function Drewlabs\GCli\Proxy\ORMModelDefinition;
//...
// Building a model
ComponentsScriptWriter(__DIR__ . '/examples/src'))->write(EloquentORMModelBuilder(ORMModelDefinition([
'primaryKey' => 'id',
'name' => null,
'table' => 'persons',
'columns' => [
ORMColumnDefinition([
'name' => 'firstname',
'type' => 'string'
]),
ORMColumnDefinition([
'name' => 'lastname',
'type' => 'string'
])
],
'increments' => false,
'namespace' => "App\\Models"
]))->build()
// To build a model as a view model
ComponentsScriptWriter(__DIR__ . '/examples/src')->write((EloquentORMModelBuilder(ORMModelDefinition([
'primaryKey' => 'id',
'name' => null,
'table' => 'humans',
'columns' => [
ORMColumnDefinition([
'name' => 'firstname',
'type' => 'string'
]),
ORMColumnDefinition([
'name' => 'lastname',
'type' => 'string'
])
],
'increments' => false,
'namespace' => "App\\Models"
])))->asViewModel()->build();
sh
php artisan drewlabs:mvc:create --http
sh
php artisan drewlabs:mvc:create --http --schema=test
sh
php artisan drewlabs:mvc:create --http --middleware=auth
sh
php artisan drewlabs:mvc:create --http --only=users
sh
php artisan drewlabs:mvc:create --http --routingfilename=api.php
sh
php artisan drewlabs:mvc:create --http --relations
sh
php artisan drewlabs:mvc:create --http --relations --manytomany=posts->post_comments->comments --manytomany=posts->post_tags->tags
sh
php artisan drewlabs:mvc:create --http --relations --toones=employees->employee_managers
sh
php artisan drewlabs:mvc:create --http --relations --manythroughs=post_types->posts->comments:comments
sh
php artisan drewlabs:mvc:create --http --policies
sh
php artisan drewlabs:mvc:make:dto --path=src --namespace=\\Application\\Dto
sh
php artisan drewlabs:mvc:make:controller --name=Posts --path=src --model="\\Application\\Models\\Comment"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.