8000 Add PHP config support for routing by fabpot · Pull Request #60232 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Add PHP config support for routing #60232

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

Merged
merged 2 commits into from
Apr 27, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Deprecate using XML routing configuration files
  • Loading branch information
fabpot committed Apr 27, 2025
commit 2a5aa45b1ea69acec7fe44a93784dfe7a0594acf
57 changes: 57 additions & 0 deletions UPGRADE-7.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,33 @@ FrameworkBundle
public function __construct(#[Autowire('@serializer.normalizer.object')] NormalizerInterface $normalizer) {}
```

* The XML routing configuration files (`errors.xml` and `webhook.xml`) are
deprecated, use their PHP equivalent ones:

*Before*
```yaml
when@dev:
_errors:
resource: '@FrameworkBundle/Resources/config/routing/errors.xml'
prefix: /_error

webhook:
resource: '@FrameworkBundle/Resources/config/routing/webhook.xml'
prefix: /webhook
```

*After*
```yaml
when@dev:
_errors:
resource: '@FrameworkBundle/Resources/config/routing/errors.php'
prefix: /_error

webhook:
resource: '@FrameworkBundle/Resources/config/routing/webhook.php'
prefix: /webhook
```

HttpFoundation
--------------

Expand Down Expand Up @@ -112,6 +139,36 @@ PropertyInfo
* Deprecate the `PropertyTypeExtractorInterface::getTypes()` method, use `PropertyTypeExtractorInterface::getType()` instead
* Deprecate the `ConstructorArgumentTypeExtractorInterface::getTypesFromConstructor()` method, use `ConstructorArgumentTypeExtractorInterface::getTypeFromConstructor()` instead

Routing
-------

* The XML routing configuration files (`profiler.xml` and `wdt.xml`) are
deprecated, use their PHP equivalent ones:

*Before*
```yaml
when@dev:
web_profiler_wdt:
resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml'
prefix: /_wdt

web_profiler_profiler:
resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml'
prefix: /_profiler
```

*After*
```yaml
when@dev:
web_profiler_wdt:
resource: '@WebProfilerBundle/Resources/config/routing/wdt.php'
prefix: /_wdt

web_profiler_profiler:
resource: '@WebProfilerBundle/Resources/config/routing/profiler.php
prefix: /_profiler
```

Security
--------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,19 @@
*/

use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use Symfony\Component\Routing\Loader\XmlFileLoader;

return function (RoutingConfigurator $routes): void {
foreach (debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT) as $trace) {
if (isset($trace['object']) && $trace['object'] instanceof XmlFileLoader && 'doImport' === $trace['function']) {
if (__DIR__ === dirname(realpath($trace['args'][3]))) {
trigger_deprecation('symfony/routing', '7.3', 'The "profiler.xml" routing configuration file is deprecated, import "profile.php" instead.');

break;
}
}
}

$routes->add('_profiler_home', '/')
->controller('web_profiler.controller.profiler::homeAction')
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,19 @@
*/

use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use Symfony\Component\Routing\Loader\XmlFileLoader;

return function (RoutingConfigurator $routes): void {
foreach (debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT) as $trace) {
if (isset($trace['object']) && $trace['object'] instanceof XmlFileLoader && 'doImport' === $trace['function']) {
if (__DIR__ === dirname(realpath($trace['args'][3]))) {
trigger_deprecation('symfony/routing', '7.3', 'The "xdt.xml" routing configuration file is deprecated, import "xdt.php" instead.');

break;
}
}
}

$routes->add('_wdt_stylesheet', '/styles')
->controller('web_profiler.controller.profiler::toolbarStylesheetAction')
;
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Bundle/WebProfilerBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"php": ">=8.2",
"composer-runtime-api": ">=2.1",
"symfony/config": "^7.3",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/framework-bundle": "^6.4|^7.0",
"symfony/http-kernel": "^6.4|^7.0",
"symfony/routing": "^6.4|^7.0",
Expand Down
Loading
0