This package adds some artisan commands to generate relations
, helpers
, scopes
, concerns
, mutators
, transformers
files and override the laravel original artisan commands as your like., (*1)
NOTE : the view artisan commands was forked from sven/artisan-view, (*2)
Via composer:, (*3)
composer require ahmed-aliraqi/artisan-scaffolding
Or add the package to your dependencies in composer.json
and run
composer update
to download the package:, (*4)
{ "require": { "ahmed-aliraqi/artisan-scaffolding": "^1.0" } }
Note: If you're using Laravel 5.5, you're done! The service provider is automatically registered in the container, thanks to auto-discovery., (*5)
Next, add the ServiceProvider
to your providers
array in config/app.php
:, (*6)
// config/app.php 'providers' => [ ... Aliraqi\Artisan\Scaffolding\Providers\ServiceProvider::class, ];
If you now run php artisan
you can see 8 new commands:
- make:helper
- make:mutator
- make:relation
- make:scope
- make:concern
- make:transformer
- make:view
- scrap:view
, (*7)
These commands was overrided by this package :
- make:model
: add the fillable as default.
- make:controller
: add generate request option and generate full resource, nested controller .
- make:policy
: add listing
method and replace the user
variable name to auther
if the created policy file name is user
- make:request
: division the rules by method name and change the authorize
method return to true by default., (*8)
If you want to change your project character run this command to publish the config file :, (*9)
php artisan vendor:publish --provider=Aliraqi\Artisan\Scaffolding\Providers\ServiceProvider --tag=config
// config/artisan-scaffolding.php <?php return [ /** * the default namespace for the models classes. * * if you change the default namespace you need to change user model namespace in these files :- * - config/auth.php * - config/services.php * - app/Http/Controllers/Auth/RegisterController.php * - database/factories/ModelFactory.php * */ 'models_default_namespace' => 'App', /** * the default namespace for the relations traits. * */ 'relations_default_namespace' => 'App\Relations', /** * the default namespace for the concerns traits. * */ 'concerns_default_namespace' => 'App\Concerns', /** * the default namespace for the mutators traits. * */ 'mutators_default_namespace' => 'App\Mutators', /** * the default namespace for the scopes traits. * */ 'scopes_default_namespace' => 'App\Scopes', /** * the default namespace for the helpers traits. * */ 'helpers_default_namespace' => 'App\Helpers', /** * the default namespace for the policies classes. * */ 'policies_default_namespace' => 'App\Policies', /** * the default namespace for the requests classes. * */ 'requests_default_namespace' => 'App\Http\Requests', /** * the default namespace for the controllers classes. * */ 'controllers_default_namespace' => 'App\Http\Controllers', /** * the default namespace for the transformer classes. * */ 'transformers_default_namespace' => 'App\Transformers', ];php artisan vendor:publish --provider=Aliraqi\Artisan\Scaffolding\Providers\ServiceProvider --tag=stubs
If you want to change stubs files content run this command :
Now you can see the stubs files in this path app\Console\stubs
, (*10)
sven/artisan-view
is licensed under the MIT License (MIT). Please see the
license file for more information., (*11)