Skip to content

Commit a65811e

Browse files
committed
minor #7810 Documented the new getProjectDir() method (javiereguiluz)
This PR was squashed before being merged into the master branch (closes #7810). Discussion ---------- Documented the new getProjectDir() method This fixes #7768. Commits ------- 51c25d8 Documented the new getProjectDir() method
2 parents 57de84c + 51c25d8 commit a65811e

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

reference/configuration/kernel.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ directory and rename it to something else (e.g. ``foo``).
5656
Root Directory
5757
~~~~~~~~~~~~~~
5858

59+
.. versionadded:: 3.3
60+
The ``getRootDir()`` method is deprecated since Symfony 3.3. Use the new
61+
``getProjectDir()`` method instead.
62+
5963
**type**: ``string`` **default**: the directory of ``AppKernel``
6064

6165
This returns the root directory of your kernel. If you use the Symfony Standard
@@ -77,6 +81,34 @@ To change this setting, override the
7781
}
7882
}
7983

84+
Project Directory
85+
~~~~~~~~~~~~~~~~~
86+
87+
.. versionadded:: 3.3
88+
The ``getProjectDir()`` method was introduced in Symfony 3.3.
89+
90+
**type**: ``string`` **default**: the directory of the project ``composer.json``
91+
92+
This returns the root directory of your Symfony project. It's calculated as
93+
the directory where the main ``composer.json`` file is stored.
94+
95+
If for some reason the ``composer.json`` file is not stored at the root of your
96+
project, you can override the :method:`Symfony\\Component\\HttpKernel\\Kernel::getProjectDir`
97+
method to return the right project directory::
98+
99+
// app/AppKernel.php
100+
101+
// ...
102+
class AppKernel extends Kernel
103+
{
104+
// ...
105+
106+
public function getProjectDir()
107+
{
108+
return realpath(__DIR__.'/../');
109+
}
110+
}
111+
80112
Cache Directory
81113
~~~~~~~~~~~~~~~
82114

0 commit comments

Comments
 (0)