Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trait 'Illuminate\Foundation\Bus\DispatchesCommands' not found error while laravel upgrading to 5.2 from 5.1?

When I am trying to upgrade from laravel 5.1 to 5.2, I am getting following error

Trait 'Illuminate\Foundation\Bus\DispatchesCommands' not found in D:\xampp\htdocs\Invoice\web\bootstrap\cache\compiled.php

My controller class is,

    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');
    }

}

In laravel documentation, they saying it deprecated

So how can I fix this?

like image 893
gsk Avatar asked Jan 04 '16 11:01

gsk


1 Answers

Deprecated doesn't mean that it's been removed, just that it will be at some point. They do mention a fix for it in the documentation:

The Illuminate\Foundation\Bus\DispatchesCommands trait has been deprecated and renamed to Illuminate\Foundation\Bus\DispatchesJobs.

So just replace this:

use Illuminate\Foundation\Bus\DispatchesCommands;

With this:

use Illuminate\Foundation\Bus\DispatchesJobs;

There should not be any worries about this breaking in the future as the DispatchesCommands trait was including the DispatchesJobs trait which was also present in another form in 5.1.

like image 165
Bogdan Avatar answered Oct 17 '22 14:10

Bogdan