Skip to content

Commit 6890cb8

Browse files
committed
minor #13819 Provides a way to override cache and log folders from the ENV (Plopix)
This PR was merged into the master branch. Discussion ---------- Provides a way to override cache and log folders from the ENV Related to this new feature symfony/symfony#37114. But I wonder if we have not oversimplified this PR: symfony/symfony#37114 Actually doing the documentation #13787 I figured that with #37114 we removed the important split per `env`. In development mode (docker or not) we could definitely have the same project working in N Symfony different environments and this new `APP_CACHE_DIR` will only set the same path for all environments. That would be manageable in the Virtualhost but in CLI that would be a pain to manage. Also, we could rely on the DotEnv mechanism, but that could be really easy to forget. I wonder if we should not change the code to: symfony/symfony#37232 Depending on the decisions I will update the doc here. Commits ------- 88b081c Provides a way to override cache and log folders from the ENV
2 parents 3a88029 + 88b081c commit 6890cb8

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

configuration/override_dir_structure.rst

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ at your project root directory.
4141
Override the Cache Directory
4242
----------------------------
4343

44-
You can change the default cache directory by overriding the ``getCacheDir()``
45-
method in the ``Kernel`` class of your application::
44+
Changing the cache directory can be achieved by overriding the
45+
``getCacheDir()`` method in the ``Kernel`` class of your application::
4646

4747
// src/Kernel.php
4848

@@ -61,6 +61,9 @@ In this code, ``$this->environment`` is the current environment (i.e. ``dev``).
6161
In this case you have changed the location of the cache directory to
6262
``var/{environment}/cache/``.
6363

64+
This can also be achieved using a predefined environment variable named
65+
``APP_CACHE_DIR``. Its value must be the full path of the cache folder.
66+
6467
.. caution::
6568

6669
You should keep the cache directory different for each environment,
@@ -73,9 +76,11 @@ In this case you have changed the location of the cache directory to
7376
Override the Log Directory
7477
--------------------------
7578

76-
Overriding the ``var/log/`` directory is the same as overriding the ``var/cache/``
77-
directory. The only difference is that you need to override the ``getLogDir()``
78-
method::
79+
Overriding the ``var/log/`` directory is almost the same as overriding the
80+
``var/cache/`` directory.
81+
82+
You can do it overriding the ``getLogDir()`` method in the ``Kernel`` class of
83+
your application::
7984

8085
// src/Kernel.php
8186

@@ -92,6 +97,8 @@ method::
9297

9398
Here you have changed the location of the directory to ``var/{environment}/log/``.
9499

100+
And you can also do it using the predefined ``APP_LOG_DIR`` environment variable.
101+
95102
.. _override-templates-dir:
96103

97104
Override the Templates Directory

0 commit comments

Comments
 (0)