Skip to content

Navigation Menu

Sign in
Appearance settings
Sign up
Appearance settings
Open
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions 14 UPGRADE-8.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ FrameworkBundle
* Deprecate the `framework.ide` config option, use the `SYMFONY_IDE` env var instead
* BrowserKit assertions are no longer verbose by default. Failed response assertions no longer include the response body unless `setBrowserKitAssertionsAsVerbose(true)` is called or `verbose: true` is passed to the assertion.
* Deprecate the `framework.fragments.hinclude_default_template` config option and the `fragment.renderer.hinclude.global_template` parameter; use the `esi` or `inline` fragment renderer, or [Symfony UX Turbo](https://ux.symfony.com/turbo), instead
* Deprecate not setting the `framework.asset_mapper.metadata_dir` config option. It currently
defaults to the public assets directory, which publishes `manifest.json`, `importmap.json` and
`entrypoint.*.json` over HTTP although they are read by PHP only. It will default to
`%kernel.build_dir%/asset_mapper` in 9.0. Set it explicitly to silence the deprecation:

```yaml
framework:
asset_mapper:
# keep the current location
metadata_dir: '%kernel.project_dir%/public/assets'

# or adopt the 9.0 default now; make sure the build directory is deployed
metadata_dir: '%kernel.build_dir%/asset_mapper'
```

HttpClient
----------
Expand Down
2 changes: 2 additions & 0 deletions 2 src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ CHANGELOG
* Add `framework.messenger.reject_redelivered_messages` to allow disabling the `RejectRedeliveredMessageMiddleware`
* Add `uri_signer.expiration` option that allows configuring the default URI signer expiration
* Add `--dispatchers` option to `debug:event-dispatcher` command
* Add `framework.asset_mapper.metadata_dir` option to choose where `asset-map:compile` writes its metadata
* Deprecate the `framework.ide` config option, use the `SYMFONY_IDE` env var instead
* Deprecate not setting `framework.asset_mapper.metadata_dir`; it will default to `%kernel.build_dir%/asset_mapper` in 9.0
* Allow prefixing entries with `!` in `framework.workflows.<name>.events_to_dispatch` to permanently disable an event; e.g. `events_to_dispatch: ['!workflow.announce']` fires every event except `workflow.announce`. The GuardEvent can never be disabled; `!workflow.guard` is rejected at config compile time. Mixing allow-list and block-list entries in the same list is rejected at config compile time too.
* Add support for the HttpClient `max_connect_duration` option to the `http_client` configuration
* Report `.env` variables that the container never uses in `debug:container --env-vars`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,10 @@ private function addAssetMapperSection(ArrayNodeDefinition $rootNode, callable $
->info('The public path where the assets will be written to (and served from when "server" is true).')
->defaultValue('/assets/')
->end()
->scalarNode('metadata_dir')
->info('The directory where "asset-map:compile" writes manifest.json, importmap.json and entrypoint.*.json. These files are read by PHP only, never fetched by the browser. Defaults to the public assets directory; will default to "%kernel.build_dir%/asset_mapper" in 9.0.')
->defaultNull()
->end()
->enumNode('missing_import_mode')
->values(['strict', 'warn', 'ignore'])
->info('Behavior if an asset cannot be found when imported from JavaScript or CSS files - e.g. "import \'./non-existent.js\'". "strict" means an exception is thrown, "warn" means a warning is logged, "ignore" means the import is left as-is.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1501,8 +1501,18 @@ private function registerAssetMapperConfiguration(array $config, ContainerBuilde
->setArgument(0, $publicDirectory)
;

if (null === $metadataDir = $config['metadata_dir']) {
// Only nag applications that actually map assets: with no path declared, nothing is
// ever compiled, so there is no metadata to place and nothing to decide.
if ($paths) {
trigger_deprecation('symfony/framework-bundle', '8.2', 'Not setting the "framework.asset_mapper.metadata_dir" configuration option is deprecated. Set it explicitly: it currently defaults to the public assets directory, and will default to "%s" in 9.0.', '%kernel.build_dir%/asset_mapper');
}

$metadataDir = $publicAssetsDirectory;
}

$container->getDefinition('asset_mapper.compiled_asset_mapper_config_reader')
->setArgument(0, $publicAssetsDirectory);
->setArgument(0, $metadataDir);

if (!$config['server']) {
$container->removeDefinition('asset_mapper.dev_server_subscriber');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ public function testAssetMapperCanBeEnabled()
'excluded_patterns' => [],
'server' => true,
'public_prefix' => '/assets/',
'metadata_dir' => null,
'missing_import_mode' => 'warn',
'extensions' => [],
'importmap_path' => '%kernel.project_dir%/importmap.php',
Expand Down Expand Up @@ -1215,6 +1216,7 @@ protected static function getBundleDefaultConfig()
'excluded_patterns' => [],
'server' => true,
'public_prefix' => '/assets/',
'metadata_dir' => null,
'missing_import_mode' => 'warn',
'extensions' => [],
'importmap_path' => '%kernel.project_dir%/importmap.php',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

$container->loadFromExtension('framework', [
'asset_mapper' => [
'paths' => ['assets/'],
],
'assets' => false,
]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

$container->loadFromExtension('framework', [
'asset_mapper' => [
'paths' => ['assets/'],
'metadata_dir' => '%kernel.build_dir%/asset_mapper',
],
'assets' => false,
]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
framework:
asset_mapper:
paths: ['assets/']
assets: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
framework:
asset_mapper:
paths: ['assets/']
metadata_dir: '%kernel.build_dir%/asset_mapper'
assets: false
Original file line number Diff line number Diff line change
Expand Up @@ -3523,6 +3523,7 @@ public function testAssetMapperDevServerPrefix(bool $server, ?string $expectedPr
'asset_mapper' => [
'server' => $server,
'public_prefix' => '/assets_path/',
'metadata_dir' => '%kernel.build_dir%/asset_mapper',
'paths' => ['assets/'],
],
]);
Expand Down Expand Up @@ -3560,6 +3561,29 @@ public function testAssetMapperImportmapEntries()
$this->assertSame('my-polyfill', $container->getDefinition('asset_mapper.importmap.renderer')->getArgument(3));
}

public function testAssetMapperMetadataDirIsConfigurable()
{
$container = $this->createContainerFromFile('asset_mapper_metadata_dir');

$this->assertSame(
$container->getParameter('kernel.build_dir').'/asset_mapper',
$container->getDefinition('asset_mapper.compiled_asset_mapper_config_reader')->getArgument(0),
);
}

#[IgnoreDeprecations]
public function testAssetMapperMetadataDirFallsBackToThePublicAssetsDirectory()
{
$this->expectUserDeprecationMessage('Since symfony/framework-bundle 8.2: Not setting the "framework.asset_mapper.metadata_dir" configuration option is deprecated. Set it explicitly: it currently defaults to the public assets directory, and will default to "%kernel.build_dir%/asset_mapper" in 9.0.');

$container = $this->createContainerFromFile('asset_mapper_default_metadata_dir');

$this->assertStringEndsWith(
'/assets',
$container->getDefinition('asset_mapper.compiled_asset_mapper_config_reader')->getArgument(0),
);
}

public function testDefaultLock()
{
$container = $this->createContainerFromFile('lock');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ framework:
translator: true
validation: true
serializer: true
asset_mapper:
metadata_dir: '%kernel.build_dir%/asset_mapper'

twig:
strict_variables: '%kernel.debug%'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
'public_prefix' => 'assets',
];

if (Kernel::VERSION_ID >= 80200) {
$assetMapper['metadata_dir'] = '%kernel.project_dir%/public/assets';
}

if ('reachable_entries' === $this->getEnvironment()) {
$assetMapper['importmap_entries'] = 'reachable';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ public function getProjectDir(): string
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load(static function (ContainerBuilder $container) {
$assetMapperConfig = ['paths' => ['assets']];

if (Kernel::VERSION_ID >= 80200) {
$assetMapperConfig['metadata_dir'] = '%kernel.project_dir%/public/assets';
}

$container->loadFromExtension('framework', [
'http_client' => true,
'assets' => null,
'asset_mapper' => [
'paths' => ['assets'],
],
'asset_mapper' => $assetMapperConfig,
'test' => true,
]);
});
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.