In my application I already use php-di/slim-bridge, where the app is created with $app = \DI\Bridge\Slim\Bridge::create($container);
I would like to use also juliangut/slim-routing library to have php attributes defined routes and other benefits.
However, in the juliangut/slim-routing usage section, I see
$configuration = new Configuration([
'sources' => ['/path/to/routing/files'],
]);
AppFactory::setRouteCollectorConfiguration($configuration);
// Instantiate the app
$app = AppFactory::create();
I don’t get how I can get the two libraries work together if $app is created in different ways.
Is there any way of achieving the integration of both libraries ?
Sure, but there is something called separation of concern. The way you wonder to apply, put together both application bootstrapping and injection definitions at the same code scope.
Look, this is certainly injection definition:
$configuration = new Configuration([
'sources' => ['/path/to/routing/files'],
]);
you will have lots of such definitions to prepare, and I assume you will do it more or less like in my definitions.php file example.
Now you have to answer yourself a question, why Configuration object is so special that you decide to instantiate it within bootstraping scope and other in definitions scope?
I say there is nothing special in Configuration object, and you have to be consistent in your code.
and this is certainly justified and correct in case if Configuration object is used exclusively as a parameter of AppFactory::setRouteCollectorConfiguration method, meaning no other object will use it. In many cases it is not, that is why my example, for a presentation purpose is more general.
Your first example was great. Thank you for your detailed reply.
I was just wondering of a simpler approach maybe because I’m an ol’ man already, and thus adhering fully to the KISS principle.
As you put it in your reply I (personally) won’t take offense of a Configuration object whatsoever in a app’s bootstrapping script, especially in term of concerns… but you are right start clean to enable a harmonious evolving is really important for long run and/or big project.