user391986
user391986

Reputation: 30946

Upgrading Laravel 5.0 to Laravel 5.1 Commands to Jobs

Laravel 5.1 is renaming Commands to Jobs and Events to Listeners. http://laravel.com/docs/5.1/releases#laravel-5.1

I was using Commands and Command Handlers in Laravel 5.0 like so.

app\Commands\MyCommand

<?php namespace app\Commands;

use app\Commands\Command;

class MyCommand extends Command
{

    public $data;

    public function __construct($data)
    {
        $this->data = $data;
    }
}

app\Handlers\Commands\MyCommand

<?php namespace app\Handlers\Commands\Genapps;

use app\Commands\MyCommand;

class MyCommandHandler
{
    public function handle(MyCommand $command)
    {

    }
}

I don't see how I'm supposed to implement the handler in Laravel 5.1?

Upvotes: 9

Views: 1546

Answers (1)

Sh1d0w
Sh1d0w

Reputation: 9520

From the 5.1 release notes:

However, this is not a breaking change and you are not required to update to the new folder structure to use Laravel 5.1.

In case you want to upgrade, you just have to rename your folder and change the namespace (Laravel uses PSR-4 autoloader in version 5, so the folder structure corresponds to the namespace of your files).

However if your project is quite large I do not recommend you that, since as the documentation states this is not required step for the upgrade your code will work just fine in 5.1. It is more like a cosmetic change.

Upvotes: 4

Related Questions