I use Symfony 5 and Solarium. I want to get the project dir (or root dir) in my Controller (extends from AbstractController).
I saw some anwers with kernel, creating new services, etc..
But, isn't it just a function that call the project dir without creating some custom services etc..?
Thanks !
You don't need any service for this. You can get from container in your controller.
$this->getParameter('kernel.project_dir');Other way is bind it on yaml.
So you can inject each service and controller as $projectDir.
https://symfony.com/doc/current/configuration.html#accessing-configuration-parameters