Skip to content

[configuration][override_dir_structure] Update override Symfony default directory structure #21257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 7.2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 58 additions & 3 deletions configuration/override_dir_structure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,41 @@ Web front-controller::
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
// ...

.. _override-bin-dir:

Override the Binary Directory
-----------------------------

You can change the binary directory by adding the ``extra.bin-dir`` option
in the ``composer.json`` file:

.. code-block:: json

{
"...": "...",
"extra": {
"...": "...",
"bin-dir": "my_new_bin_dir"
}
}

.. _override-config-dir:

Override the Configuration Directory
------------------------------------

The configuration directory is the only one which cannot be overridden in a
Symfony application. Its location is hardcoded as the ``config/`` directory
at your project root directory.
You can change the configuration directory by adding the ``extra.config-dir`` option
in the ``composer.json`` file:

.. code-block:: json

{
"...": "...",
"extra": {
"...": "...",
"config-dir": "my_new_config_dir"
}
}

.. _override-cache-dir:

Expand Down Expand Up @@ -147,6 +174,34 @@ Here you have changed the location of the directory to ``var/{environment}/log/`
You can also change the log directory defining an environment variable named
``APP_LOG_DIR`` whose value is the full path of the log folder.

.. _override-src-dir:

Override the Source Directory
-----------------------------

You can change the source directory by adding the ``extra.src-dir`` option
and updating the ``autoload.psr-4`` option in the ``composer.json`` file:

.. code-block:: json

{
"...": "...",
"autoload": {
"psr-4": {
"App\\": "my_new_src_dir/"
}
},
"extra": {
"...": "...",
"src-dir": "my_new_src_dir"
}
}

.. tip::

Don't forget to run the ``composer dump-autoload`` command once ``autoload.psr-4``
has been changed.

.. _override-templates-dir:

Override the Templates Directory
Expand Down