LaravelCollective/bus

How to install on Lumen 5.2

Closed this issue · 2 comments

I am using this library in a Laravel package and I would like to use that package on a Lumen application.

I have added this to my app.php file:

$app->register(Collective\Bus\BusServiceProvider::class);
$app->register(MyServiceProvider::class);

And this is my service provider:

use Collective\Bus\Dispatcher;
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;

class MyServiceProvider extends ServiceProvider
{
    public function boot(Dispatcher $dispatcher)
    {
        $this->loadViewsFrom(realpath(__DIR__ . '/resources/views'), 'mymodule');

        $this->setupRoutes($this->app->router);

        $this->publishes([
            __DIR__ . '/config/mymodule.php' => config_path('mymodule.php'),
        ]);

        $dispatcher->mapUsing(function ($command) {
            $handler = str_replace('\\Command\\', '\\Handlers\\', get_class($command));
            $handler .= 'Handler@handle';
            return $handler;
        });
    }

    ...
}

And I get this error:

Argument 1 passed to MyServiceProvider::boot() must be an instance of Collective\Bus\Dispatcher, none given, called in /home/vagrant/josecelano/Code/BaseLumenApp/vendor/laravel/lumen-framework/src/Application.php on line 170 and defined

This package is not designed for lumen, and, infact doesn't work on lumen.

OK, thanks.