-
-
Notifications
You must be signed in to change notification settings - Fork 39
Support for Laravel Lumen? #41
-
Anyone any luck trying to get this project to work on Laravel Lumen?
I have tried adding
$app->register(Stackkit\LaravelGoogleCloudTasksQueue\CloudTasksServiceProvider::class);
To my bootstrap/app.php file
But I'm getting the error:
Unresolvable dependency resolving [Parameter #0 [ <required> $app ]] in class Illuminate\Queue\QueueManager
Anyone?
Beta Was this translation helpful? Give feedback.
All reactions
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
$app->bind(Illuminate\Queue\QueueManager::class, function ($app) { return $app['queue']; });
Problem 2 - Router dependency
The package needs Illuminate\Routing\Router
and Lumen doesn't have it. You ...
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 resolving
Not sure why this happens, but others have reported it too.
This is fixed by adding these lines to bootstrap/app.php
$app->bind(Illuminate\Queue\QueueManager::class, function ($app) { return $app['queue']; });
Problem 2 - Router dependency
The package needs Illuminate\Routing\Router
and Lumen doesn't have it. You can trick the package into loading a fake 'Illuminate' router which is actually the Lumen router.
Add this class to your project:
<?php namespace App; class Router extends \Laravel\Lumen\Routing\Router { }
Then add the following to bootstrap/app.php
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 bootstrap/app.php
again):
$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.