feature #37114 Provides a way to override cache and log folders from the ENV (Plopix)

This PR was merged into the 5.2-dev branch.

Discussion
----------

Provides a way to override cache and log folders from the ENV

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| License       | MIT

When using Docker and especially on Mac OS X, performances are terrible when using a "mount" on the host inside the container. (which happens by default)

To optimize the performances, one of the tricks is to change where the application is going to write the cache and the logs.

This PR provides a new env variables `APP_CACHE_DIR` and `APP_LOG_DIR` which can be set to change where will be saved the caches and the logs.

I know we can do it per project BUT:
- I think that is a good addition to Symfony
- it would allow project like eZ Platform and eZ Launchpad to automate that optimization
https://github.com/ezsystems/ezplatform/pull/543

Let me know

Commits
-------

5fa5d36153 Provides a way to override cache and log folders form the ENV
This commit is contained in:
Fabien Potencier 2020-06-09 13:19:08 +02:00
commit 691b604972
1 changed files with 16 additions and 0 deletions

View File

@ -63,6 +63,22 @@ trait MicroKernelTrait
*/
//abstract protected function configureContainer(ContainerConfigurator $c): void;
/**
* {@inheritdoc}
*/
public function getCacheDir(): string
{
return $_SERVER['APP_CACHE_DIR'] ?? parent::getCacheDir();
}
/**
* {@inheritdoc}
*/
public function getLogDir(): string
{
return $_SERVER['APP_LOG_DIR'] ?? parent::getLogDir();
}
/**
* {@inheritdoc}
*/