Can Laravel generate all mvc skeleton out of an existing table like that of cakephp's command cake bake all

491 Views Asked by At

I found laravel very interesting. But I'm wondering if there's any artisan command to generate all MVC skeleton files provided a database table all at ones. And how about separate generation of especially the model, given the table structure? or is there any alternative way to do the code generating?

2

There are 2 best solutions below

0
Gammer On

You can create a migration file from the table via the package below.

https://github.com/Xethron/migrations-generator

Install it via : composer require --dev "xethron/migrations-generator"

Follow the package instructions, After connecting you application with the database simply run php artisan migrate:generate.

You will see number of migrations created via console message, You can also check your database/migrations folder for confirmation.

0
Gonzalo On

I didn't find how to do that, so I created my own code in order to create the models: https://github.com/Triun/laravel-model-base

It is not super documented, but you can actually write your own addons in order to add custom business behaviors or include your own interfaces or traits to your models, with your own code.

And of course, reports and contributions are more than welcome.

I hope this helps.