Skip to content

Commit 29d7a4d

Browse files
[HttpKernel] Add KernelInterface::getShareDir(), APP_SHARE_DIR and %kernel.share_dir% to store application data that are shared between all front-end servers
1 parent 1b0c422 commit 29d7a4d

File tree

6 files changed

+14
-3
lines changed

6 files changed

+14
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ CHANGELOG
2020
* Initialize `router.request_context`'s `_locale` parameter to `%kernel.default_locale%`
2121
* Deprecate `ConfigBuilderCacheWarmer`, return PHP arrays from your config instead
2222
* Add support for selecting the appropriate error renderer based on the `APP_RUNTIME_MODE` env var
23+
* Add `KernelInterface::getShareDir()`, `APP_SHARE_DIR` and `%kernel.share_dir%` to store application data that are shared between all front-end servers
2324

2425
7.3
2526
---

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,7 @@ private function addCacheSection(ArrayNodeDefinition $rootNode, callable $willBe
13851385
->info('System related cache pools configuration.')
13861386
->defaultValue('cache.adapter.system')
13871387
->end()
1388-
->scalarNode('directory')->defaultValue('%kernel.cache_dir%/pools/app')->end()
1388+
->scalarNode('directory')->defaultValue('%kernel.share_dir%/pools/app')->end()
13891389
->scalarNode('default_psr6_provider')->end()
13901390
->scalarNode('default_redis_provider')->defaultValue('redis://localhost')->end()
13911391
->scalarNode('default_valkey_provider')->defaultValue('valkey://localhost')->end()

Kernel/MicroKernelTrait.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ public function getBuildDir(): string
124124
return parent::getBuildDir();
125125
}
126126

127+
public function getShareDir(): string
128+
{
129+
if (isset($_SERVER['APP_SHARE_DIR'])) {
130+
return $_SERVER['APP_SHARE_DIR'].'/'.$this->environment;
131+
}
132+
133+
return parent::getShareDir();
134+
}
135+
127136
public function getLogDir(): string
128137
{
129138
return $_SERVER['APP_LOG_DIR'] ?? parent::getLogDir();

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ protected static function getBundleDefaultConfig()
936936
'pools' => [],
937937
'app' => 'cache.adapter.filesystem',
938938
'system' => 'cache.adapter.system',
939-
'directory' => '%kernel.cache_dir%/pools/app',
939+
'directory' => '%kernel.share_dir%/pools/app',
940940
'default_redis_provider' => 'redis://localhost',
941941
'default_valkey_provider' => 'valkey://localhost',
942942
'default_memcached_provider' => 'memcached://localhost',

Tests/DependencyInjection/FrameworkExtensionTestCase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2852,6 +2852,7 @@ protected function createContainer(array $data = [])
28522852
'kernel.bundles_metadata' => ['FrameworkBundle' => ['namespace' => 'Symfony\\Bundle\\FrameworkBundle', 'path' => __DIR__.'/../..']],
28532853
'kernel.cache_dir' => __DIR__,
28542854
'kernel.build_dir' => __DIR__,
2855+
'kernel.share_dir' => __DIR__,
28552856
'kernel.project_dir' => __DIR__,
28562857
'kernel.debug' => false,
28572858
'kernel.environment' => 'test',

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"symfony/filesystem": "^7.1|^8.0",
2929
"symfony/finder": "^6.4|^7.0|^8.0",
3030
"symfony/http-foundation": "^7.4|^8.0",
31-
"symfony/http-kernel": "^7.2|^8.0",
31+
"symfony/http-kernel": "^7.4|^8.0",
3232
"symfony/polyfill-mbstring": "~1.0",
3333
"symfony/polyfill-php85": "^1.32",
3434
"symfony/routing": "^7.4|^8.0"

0 commit comments

Comments
 (0)