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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With