从Laravel 4.2 Controller运行Artisan Command [英] Running Artisan Command from laravel 4.2 Controller

查看:274
本文介绍了从Laravel 4.2 Controller运行Artisan Command的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从

这样的控制器执行一些自定义工匠命令

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

但是当我执行

时效果很好

php artisan MuCustomCommand from CLI.

我已经在app/start/artisan.php.中注册了命令 甚至Artisan::call('php artisan --help');都不起作用.

解决方案

您应该从控制器运行像这样的artisan命令. 例子:

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

所以不要做Artisan::call('php artisan MyCustomCommand');

您应该

Artisan::call('MyCustomCommand');

这是文档

希望它会有所帮助:)

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.

解决方案

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 :)

这篇关于从Laravel 4.2 Controller运行Artisan Command的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆