Hi,
So basically, I'm porting my Laravel App to Lumen and in Laravel, I'm binding a repo to an implementation dynamically based on the route param passed and it works good for my purpose, even though i believe it's not a right method but it does the job!
However, It seems like Lumen doesn't support route binding and I'm having trouble binding my repo to an implementation based on the route param.
I've been trying for the past 2 days with several methods such as using Middleware (It seems even $request->route('param') doesn't work with Lumen), Service Provider, etc.
The idea is simple, Based on the param, I check to see if there's an implementation for the requested page and if yes, then bind it to the repo that's being injected in my controller, if there isn't any, then it goes with the default implementation.
This is a requirement so i can process the request based on each page that varies from each other in terms of logics, config and various other things.
Here's my Laravel specific codes that are added in RouteServiceProvider.php
$router->bind('topic', function ($topic) {
$namespace = 'App\Repositories\Topics\\';
$repo_name = $namespace . studly_case($topic);
$repo = class_exists($repo_name) ? $repo_name : $namespace . 'DefaultRepository';
$this->app->bind($namespace . 'Repository', $repo);
return $topic;
});
This works fine as i said. How would you port this to Lumen though?
Any help is highly appreciated. TIA!