当我尝试从laravel 5.1升级到5.2时,我遇到以下错误
Trait 'Illuminate\Foundation\Bus\DispatchesCommands' not found in D:\xampp\htdocs\Invoice\web\bootstrap\cache\compiled.php
我的控制器类是,
namespace App\Http\Controllers; use Illuminate\Foundation\Bus\DispatchesCommands; use Illuminate\Routing\Controller as BaseController; use Illuminate\Foundation\Validation\ValidatesRequests; abstract class Controller extends BaseController { use DispatchesCommands, ValidatesRequests; function __construct() { $this->middleware('auth'); }
}
在laravel文档中,他们说它已被弃用
那么我该如何解决这个问题呢?
不推荐使用并不意味着它已被删除,只是它会在某个时刻被删除.他们确实在文档中提到了它的修复:
该
Illuminate\Foundation\Bus\DispatchesCommands
特征已被弃用并重命名为Illuminate\Foundation\Bus\DispatchesJobs
.
所以只需替换它:
use Illuminate\Foundation\Bus\DispatchesCommands;
有了这个:
use Illuminate\Foundation\Bus\DispatchesJobs;
由于DispatchesCommands
特质包括DispatchesJobs
5.1中另一种形式的特征,因此不应该担心将来会出现这种情况.