在 Laravel 4 中如何通过 Web 界面调用 Artisan 命令?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14278685/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 07:28:57  来源:igfitidea点击:

In Laravel 4 how to call Artisan command through web interface?

phplaravel

提问by ahmed

In Laravel 4how to call Artisan commands through web interface?

Laravel 4 中如何通过 Web 界面调用 Artisan 命令?

I have tried the following

我已经尝试了以下

$command = "controller:make";
$parameters = array('name' => 'FooController');
Artisan::call($command,$parameters);

however I am getting this error message

但是我收到此错误消息

 InvalidArgumentException: There are no commands defined in the "controller" namespace.

any idea?

任何的想法?

回答by msurguy

There's now a bundle that does exactly this called WebArtisan, please see this page for more:

现在有一个名为 WebArtisan 的捆绑包,请参阅此页面了解更多信息:

http://forums.laravel.io/viewtopic.php?id=10334

http://forums.laravel.io/viewtopic.php?id=10334

If you find this helpful please mark my answer.

如果您觉得这有帮助,请标记我的答案。

回答by user2959496

Did you register your command? I have no problems at all calling a artisan command through the web using Arisan:call(). I did not install a bundle for it.

你注册你的命令了吗?我使用 Arisan:call() 通过网络调用 artisan 命令完全没有问题。我没有为它安装一个包。

回答by Laurence

Artisan is not designed to be called via the web.

Artisan 并非旨在通过网络调用。

However, if you need to, you can use this bundlewhich will allow you to expose Artisan to the web.

但是,如果需要,您可以使用此包,它允许您将 Artisan 公开给网络。

Make sure you read the bit about not using it in production, or adding some sort of password protect option!

确保您阅读了有关不在生产中使用它或添加某种密码保护选项的内容!