Laravel 4 生成不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22478135/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 4 generate not working
提问by user3367831
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
“generate”命名空间中没有定义命令
回答by Antonio Carlos Ribeiro
The generate command is from the JeffreyWay/Laravel-4-Generatorspackage, to install it you have to execute
generate 命令来自JeffreyWay/Laravel-4-Generators包,要安装它你必须执行
composer require way/generators 2.*
And then add this line to your app/config/app.php
in the Service Providers array:
然后将此行添加到您app/config/app.php
的 Service Providers 数组中:
'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
回答by KarteekM
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.
为避免它,请务必在执行该过程之前进行“作曲家更新”。
回答by Paulo Reis
Try php artisan controller:make features
尝试 php artisan 控制器:制作功能
回答by Sunil Thakur
The correct command is:
正确的命令是:
php artisan controller:make features