In Symfony 3.3, we introduce many changes and simplifications to prepare us for the exciting release of Symfony 4.0 in November 2017.
Some of these changes are technically minor, but will have a profound effect in your applications. In Symfony applications, the well-known getRootDir () method of the Kernel class and its analogue to the kernel.root_dir parameter are misleading.
They return the path in which the application kernel is stored (usually AppKernel.php). In Symfony 2 and 3, this is usually the app / directory, so expressions like% kernel.root_dir% / .. / var / or% kernel.root_dir% / .. / web / are usually used. In Symfony 4, the kernel class was moved to the src / directory, so previous expressions will not be broken.
However, given that in most cases, getRootDir () is used to get the project root directory, in Symfony 3.3 we decided to add a new method to the Kernel class called getProjectDir (), which will give you exactly that.
This new method finds the root directory of the project by looking for the first directory containing the composer.json file, starting with the directory in which the kernel is stored and continues until the composite is found. json
In practice, this means that your application can simplify most or all of the expressions that use% kernel.root_dir%. For example: use% kernel.project_dir% / web / instead of% kernel.root_dir% / .. / web /.
From: New in Symfony 3.3: Easier way to get the project root directory
source share