Support for Laravel Lumen? #41
-
Anyone any luck trying to get this project to work on Laravel Lumen? But I'm getting the error: Anyone? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey, first things first, I'd like to say that I never tested this package with Lumen and I'm not sure I want to support it, because it's not as widely used, and it seems like most people are using plain Laravel or Octane to get more performance out of Laravel. That said, I got it working, but it's very hacky and has a few problems: Problem 1 - Unsolvable dependency resolvingNot sure why this happens, but others have reported it too. This is fixed by adding these lines to $app->bind(Illuminate\Queue\QueueManager::class, function ($app) {
return $app['queue'];
}); Problem 2 - Router dependencyThe package needs Add this class to your project: <?php
namespace App;
class Router extends \Laravel\Lumen\Routing\Router
{
} Then add the following to class_alias(App\Router::class, \Illuminate\Routing\Router::class);
$app->bind(\Illuminate\Routing\Router::class, function ($app) {
return new Router($app);
}); Problem 3 - Still router issues 🙃The package registers the route like this: $router->post('handle-task', [TaskHandler::class, 'handle']); I think Lumen doesn't understand it, because the route is not working. To fix it, register it manually (in $app->router->post('/handle-task', function () {
return app(Stackkit\LaravelGoogleCloudTasksQueue\TaskHandler::class)->handle();
}); That made it work in the sense that a simple job is processed, but honestly not sure about the other features like different queues, scheduling, etc! So yeah, quite hacky, but hope it helped! |
Beta Was this translation helpful? Give feedback.
Hey, first things first, I'd like to say that I never tested this package with Lumen and I'm not sure I want to support it, because it's not as widely used, and it seems like most people are using plain Laravel or Octane to get more performance out of Laravel.
That said, I got it working, but it's very hacky and has a few problems:
Problem 1 - Unsolvable dependency resolving
Not sure why this happens, but others have reported it too.
This is fixed by adding these lines to
bootstrap/app.php
Problem 2 - Router dependency
The package needs
Illuminate\Routing\Router
and Lumen doesn't have it. You …