symfony

Get the path of a directory inside a bundle in Symfony


From inside a controller I need to get the path of one directory inside a bundle. So I have:

class MyController extends Controller{

    public function copyFileAction(){
        $request = $this->getRequest();

        $directoryPath = '???'; // /web/bundles/mybundle/myfiles
        $request->files->get('file')->move($directoryPath);

        // ...
    }
}

How to get correct $directoryPath?


Solution

  • Something like this:

    $directoryPath = $this->container->getParameter('kernel.root_dir') . '/../web/bundles/mybundle/myfiles';