Laravel RAD Package based on Laravel-5-Generators-Extended
After install fresh Laravel application:
- Install preset
composer require laravelha/preset-api --dev
orcomposer require laravelha/preset-web --dev
- Run preset
php artisan preset ha-api
orphp artisan preset ha-web --option=auth
- Via
composer require laravelha/generator --dev
- Run
php artisan ha-generator:<COMMAND> <ARGUMENTS> <OPTIONS>
to create automatically generated code. - The following commands are available.:
ha-generator:migration "Create a new migration class and apply schema at the same time"
ha-generator:model "Create a new model class and apply schema at the same time"
ha-generator:factory "Create a new factory class and apply schema at the same time"
ha-generator:requests "Create a new requests class and apply schema at the same time"
ha-generator:controller "Create a new controller and resources for api"
ha-generator:resources "Create a new resources class and apply schema at the same time"
ha-generator:route "Insert new resources routes"
ha-generator:test "Create a new feature test and apply schema at the same time"
ha-generator:lang "Create a new lang resource and apply schema at the same time"
ha-generator:view "Create a new views resource and apply schema at the same time"
ha-generator:breadcrumb "Insert new resources breadcrumb"
ha-generator:nav "Insert new nav item"
ha-generator:crud "Run all commands"
ha-generator:existing:crud "Run all commands from a existing database"
ha-generator:package "Create scaffolding structure to packages"
- For more information for each command use:
php artisan help ha-generator:<COMMAND>
This is my approach to use it.
- Install laravel fresh application
composer create-project --prefer-dist laravel/laravel blog && cd blog
- Make the first commit
git init
git add .
git commit -m 'feat: install laravel fresh app'
- Install Laravelha/Preset for your case
composer require laravelha/preset-web --dev
- Run preset
php artisan preset ha-web --option=auth
- Make the commit
git add .
git commit -m 'feat: install and run laravel laravelha/preset-web with auth'
- Install generator and publish config
composer require laravelha/generator --dev
php artisan vendor:publish --tag=ha-generator
- Run crud generator
php artisan ha-generator:crud Category -s 'title:string(150), description:text:nullable, published_at:timestamp:nullable'
- Commit then
git add .
git commit -m 'feat: create category crud by generator'
- Run other crud generator
php artisan ha-generator:crud Post -s 'title:string(150), content:text, published_at:timestamp:nullable, category_id:unsignedBigInteger:foreign'
- Commit last crud
git add .
git commit -m 'feat: create post crud by generator'
It is very important that the stage is clean before running the generator, because if you give up what was generated it is possible to undo completely with
git clean -fd; git checkout .
Every command generated is store on /storage/logs, if you need detailer each command within crud, use the option
--log-details
app/
├── <SINGULAR_CLASS_NAME>.php
│
└── Http
├── Controllers
| ├── Auth
| ├── IndexController.php
| └── <SINGULAR_CLASS_NAME>Controller.php
|
└── Requests
└── Requests
├── <SINGULAR_CLASS_NAME>StoreRequest.php
└── <SINGULAR_CLASS_NAME>UpdateRequest.php
config/
└── ha-generator.php
database
├── factories
| └── <SINGULAR_CLASS_NAME>Factory.php
|
└── migrations
└── YYYY_MM_DD_HHmmSS_create_<PLURAL_CLASS_NAME>_table.php
resources
├── lang/pt-br
| └── <PLURAL_CLASS_NAME>.php
|
└── views
└── <PLURAL_CLASS_NAME>
├── create.blade
├── delete.blade
├── edit.blade
├── index.blade
└── show.blade
routes
├── api.php
├── breadcrumbs.php
└── web.php
API api generated from generator
WEB web application generated from generator