DEV Community

Tefoh
Tefoh

Posted on

Laravel scaffold command

Hi artisans, i created a package called Laravel scaffold command, adds an artisan command that you can generate necessary files for crud applications, either you use laravel as fullstack or a rest-api this can help you.

installation

composer require tefoh/laravel-scaffold-command
// then
php artisan vendor:publish --tag=scaffold-stubs
Enter fullscreen mode Exit fullscreen mode

Thats it and just enter the model or entity you want crud operation with the fields needed. The fields is two parts, first is field name and second is field type this two separated with a colon. The field type must be from laravel migrations available column types, heres the link https://laravel.com/docs/8.x/migrations#available-column-types. For example to create a crud operation for Category enter this:

php artisan scaffold Category --fields=name:string,slug:string,parent_id:foreignId
Enter fullscreen mode Exit fullscreen mode

And for rest-api just add api parameter to create necessary resources instead of views. And controller will be a bit different:

php artisan scaffold Tag --api --fields=name:string,slug:string,parent_id:foreignId
Enter fullscreen mode Exit fullscreen mode

The original idea comes from ruby on rails, they have a similar command. The beauty of this package is you can use laravel stubs and fully customize how controllers and views created when you enter this command. I hope this will be helpful for you :)

Top comments (0)