phplumen

Lumen and passport integration


Implementing the passport library in lumen:

https://github.com/dusterio/lumen-passport

I am getting this output when performing php artisan migrate

In Facade.php line 338:

Call to undefined method Laravel\Lumen\Routing\Router::middleware()

As you can see there is the line:

$app->routeMiddleware([
     'auth' => App\Http\Middleware\Authenticate::class,
 ]); 

I also add the sentences:

\Dusterio\LumenPassport\LumenPassport::routes($app);

This is app.php

<?php

require_once __DIR__.'/../vendor/autoload.php';

(new Laravel\Lumen\Bootstrap\LoadEnvironmentVariables(
    dirname(__DIR__)
))->bootstrap();


date_default_timezone_set(env('APP_TIMEZONE', 'UTC'));

$app = new Laravel\Lumen\Application(
    dirname(__DIR__)
);

$app = new \Dusterio\LumenPassport\Lumen7Application(
    dirname(__DIR__)
);

$app->configure('auth');

 $app->withFacades();

 $app->withEloquent();


$app->singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class,
    App\Exceptions\Handler::class
);

$app->singleton(
    Illuminate\Contracts\Console\Kernel::class,
    App\Console\Kernel::class
);


$app->configure('app');

$app->configure('oracle');
$app->configure('database');


 $app->routeMiddleware([
     'auth' => App\Http\Middleware\Authenticate::class,
 ]);

$app->register(App\Providers\AppServiceProvider::class);

$app->register(\Illuminate\Mail\MailServiceProvider::class);


$app->register(Laravel\Passport\PassportServiceProvider::class);
$app->register(Dusterio\LumenPassport\PassportServiceProvider::class);
\Dusterio\LumenPassport\LumenPassport::routes($app);

$app->router->group([
    'namespace' => 'App\Http\Controllers',
], function ($router) {
    require __DIR__.'/../routes/api.php';
});

return $app;

Is there something I am omitting? since I have implemented everything verbatim from the repository.


Solution

  • You should install using laravel/passport 10:

    composer require dusterio/lumen-passport laravel/passport:^10.*
    

    The error is a bug of laravel/passport 11