问题描述
我想在控制器中不使用 shell 命令运行 composer dump-autoload
.
在 laravel 4 中,我使用 Artisan::call('dump-autoload');
但是在 laravel 5 中这个命令不起作用.
I want to run composer dump-autoload
without shell command in controller.
In laravel 4 I use Artisan::call('dump-autoload');
but in laravel 5 this command not work.
推荐答案
Artisan 不是 composer
的包装器.Composer本身自带composer
命令来控制自己.
Artisan is not wrapper for composer
. Composer itself brings the composer
command to control itself.
目前没有办法以 proper 方式从 Artisan 调用 composer
命令 - 即使使用 php artisan make:console 创建自己的 Artisan 命令也不行命令名
.
Currently there is no way to call composer
commands in a proper way from Artisan - not even with creating your own Artisan command with php artisan make:console CommandName
.
除非你不想使用 PHP 的 exec
或 system
,我强烈不推荐,你最好运行 composer dump-autoload
独立.
Unless you don't want to use PHPs exec
or system
, which I highly do not recommend, you better run composer dump-autoload
on its own.
这篇关于在 laravel 5 中从控制器运行 composer dump-autoload的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!