How to get the path to the Resources / Configuration folder in a Symfony2 controller?

How do I get the path to the Resources / config folder as a string in the controller context in Symfony 2?

I tried to look into the container, but did not notice anything.

+6
source share
3 answers

There is no built-in method to extract it, but it is easy to understand.

Inside the controller:

__DIR__.'/../Resources/config' 

In fact, you will see your package extension class using it in the load() method.

+8
source

Or you can get the kernel service and then run

 $kernel->locateResource('@NameOfBundle/Resources/config/filename'); 
+7
source
 $this->get('kernel')->getRootDir() . '/config'; 

getRootDir () always points to the application folder.

0
source

Source: https://habr.com/ru/post/903682/


All Articles