Running Artisan Command from laravel 4.2 Controller

对着背影说爱祢 提交于 2019-12-10 19:35:16

问题


I am trying to execute some custom artisan command from controller like

Artisan::call('php artisan MyCustomCommand');

but it works fine when I execute

php artisan MuCustomCommand from CLI.

I have registered command in app/start/artisan.php. Even Artisan::call('php artisan --help'); is not working.


回答1:


You should run artisan command like this from your controller . Example :

 Artisan::call('migrate:install');

So Instead of doing Artisan::call('php artisan MyCustomCommand');

You should do

Artisan::call('MyCustomCommand');

Here is the documentation

Hope it helps :)



来源:https://stackoverflow.com/questions/35125338/running-artisan-command-from-laravel-4-2-controller

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