How to get the root dir of the Symfony2 application?

前端 未结 5 1266
耶瑟儿~
耶瑟儿~ 2021-01-29 23:36

What is the best way to get the root app directory from inside the controller? Is it possible to get it outside of the controller?

Now I get it by passing it (from param

5条回答
  •  面向向阳花
    2021-01-29 23:40

    In Symfony 3.3 you can use

    $projectRoot = $this->get('kernel')->getProjectDir();
    

    to get the web/project root.

提交回复
热议问题