From a Symfony 4 project, Is there a properly/symfony way for get the root path directory from a Fixture class ?
The final goal :
I use fixtures class for load some "default" datas in my database when I deploy my website. (May be its not a good practice)
Among theses defaults datas, I need to store the root path directory of the project because I need this information from custom utils and services class in the project.
I know there are multiple ways for that. Currently, I hard coded the absolute path ( <= best ugliest way ever ;) )
__DIR__. However most fixtures are expected to be isolated from your application configuration. Please update your question to show what you have tried so far and we can help you with any issues you are encountering. If you need some direction, I suggest looking at the Symfony tests, which use aKernelMockto determine how they are using it.AppKernelin your data fixture, for the desired environment. e.g.$kernel = new AppKernel('dev');Then retrieve the root dir by using$kernel->getRootDir();or$kernel->getProjectDir();depending on the context, since they use__DIR__by default.this->get('kernel')->getProjectDir()