i have some config file which return array of key-value
return [
'my_key' => 'my value',
];
i have added it to the php-di container as definition
$builder->addDefinitions(dirname(__DIR__) . '/config.php');
$container = $builder->build();
question is how to access data from the config file inside some method of the class which is used inside di container ?
lets say i have some classes
class App
{
private $router;
public function __construct(Router $router, Request $request)
{
$this->router = $router;
$this->router->doSmth();
}
}
class Router
{
public function doSmth()
{
// how to access here to the config.php data to receive 'my value'
}
}
so when i call
$container->get('\Core\App');
everything starts but i have no idea how to access the definitions data inside the methods of the registered classes because i dont have container instance inside the container itself to call smth like
$container->get('my_key'); // return 'my value'