【发布时间】:2016-05-09 14:20:32
【问题描述】:
我正在尝试从控制器执行一些自定义工匠命令,例如
Artisan::call('php artisan MyCustomCommand');
但是当我执行时它工作正常
php artisan MuCustomCommand from CLI。
我已经在app/start/artisan.php.注册了命令
即使Artisan::call('php artisan --help'); 也不起作用。
【问题讨论】:
-
你在运行 php artisan 时看到你的自定义命令了吗??
-
是的,我的自定义命令在命令列表中。
-
你有什么错误或什么吗??
-
我认为使用 laravel 4.2 你不能通过代码运行命令。因为他们的文档也没有显示任何与此相关的信息。由于您使用的代码在 laravel 5.1 和 5.2 中可用,您必须在
app/Console/Kernel.php文件中注册您的命令。 -
Artisan::call('php artisan MyCustomCommand') 执行时返回“InvalidArgumentException Command "php artisan CustomCommand" is not defined。”
标签: php laravel-artisan laravel-4.2