symfony-config-component

How to get the root dir of the Symfony2 application?

ぃ、小莉子 提交于 2019-12-03 00:28:57
问题 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 parameters) to the service as an argument, like this: services: sr_processor: class: Pro\Processor arguments: [%kernel.root_dir%] Is there a better, simpler way to get this information in Symfony2? 回答1: UPDATE 2018-10-21: As of this week, getRootDir() was deprecated. Please use getProjectDir() instead, as suggested in the comment