Laravel generate models, views and controllers from database or migration script

大憨熊 提交于 2019-12-10 00:03:05

问题


I am new to Laravel 4. I wanted to know if it is possible to generate Models , Views and Controllers from existing database? I Googled and found

https://github.com/JeffreyWay/Laravel-4-Generators

But it allow to generate migration script, model, views and controllers by providing resource name where as i want to reverse engineering of the same in which by command line i want to create models, views and controllers from the existing database.


回答1:


php artisan generate:model dbtablename

it will create individual model from your existing database. In this case you won't need the generate:resource command.

php artisan generate:resource command

Laravel-4 Generators is very well documented. Read it thoroughly and you have fun.

If you're using Laravel 5, you might want to consider the Laravel 5 Extended Generators package.




回答2:


I've had the same question, and couldn't find a good solution, so I started to build my own.

https://github.com/jimbolino/laravel-model-builder/

It's far from perfect, but is able to do the basic things like:

  • Generate models
  • Detect relations (probably buggy)
  • Detect dates, auto increments
  • Hidden fields (if you add a mysql comment)



回答3:


Laravel 4 Migrations Generator: Automatically generates your migrations from an existing database schema. You will also find there the solution for Laravel-5.

At packalyst.com you will find how to generate the model automatically.



来源:https://stackoverflow.com/questions/24052037/laravel-generate-models-views-and-controllers-from-database-or-migration-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!