My Slim project is organized as follows:
- app
-- Acme
-- config
-- routes
-- views
- public
- vendor
I configure my application in the usual way.
$app = new \Slim\Slim([
'view' => new \Slim\Views\Twig(),
'mode' => 'development'
]);
And injecting dependencies like this.
$app->auth = function($app) {
return new Codecourse\Auth\Auth($app->user);
};
What is the best way to let my auth class see my configuration? I was originally going to pass it as a dependency, but access to the Slim configuration keys is like $app->config('key')that, so I would have to go into $appthat, which would be bad.
I know that my authentication can be used as middleware, but I would like to have access to configurations all over the world.
Perhaps it would be better to use a package like noodlehaus / config ( https://github.com/noodlehaus/config ) to handle the configuration outside Slim?