Laravel 4 generate not working

本秂侑毒 提交于 2019-12-04 08:37:04

问题


I am new to frameworks please help me out with this. I am trying to create a file in controller using generate. The following is the command

php artisan generate:controller features

it gives me the error

[InvalidArgumentException]

There are no command defined in the "generate" namespace


回答1:


The generate command is from the JeffreyWay/Laravel-4-Generators package, to install it you have to execute

composer require way/generators 2.*

And then add this line to your app/config/app.php in the Service Providers array:

'Way\Generators\GeneratorsServiceProvider'

After it just execute

php artisan

And check if you have the following commands available:

generate
  generate:controller          Generate a controller
  generate:migration           Generate a new migration
  generate:model               Generate a model
  generate:pivot               Generate a pivot table
  generate:publish-templates   Copy generator templates for user modification
  generate:resource            Generate a new resource
  generate:scaffold            Scaffold a new resource (with boilerplate)
  generate:seed                Generate a database table seeder
  generate:view                Generate a view



回答2:


By following the above procedure you might sometimes face this kind of error:

{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException",

To avoid it be sure to do "composer update" before following the procedure.




回答3:


Try php artisan controller:make features




回答4:


The correct command is:

php artisan controller:make features


来源:https://stackoverflow.com/questions/22478135/laravel-4-generate-not-working

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