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
Next Next commit
Add PHP config support for routing
  • Loading branch information
fabpot committed Apr 27, 2025
commit 2491a282d50cecbf362f85374c1965a208caadf4
1 change: 1 addition & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CHANGELOG
7.3
---

* Add `errors.php` and `webhook.php` routing configuration files (use them instead of their XML equivalent)
* Add support for the ObjectMapper component
* Add support for assets pre-compression
* Rename `TranslationUpdateCommand` to `TranslationExtractCommand`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?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.
*/

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

return function (RoutingConfigurator $routes): void {
$routes->add('_preview_error', '/{code}.{_format}')
->controller('error_controller::preview')
->defaults(['_format' => 'html'])
->requirements(['code' => '\d+'])
;
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,5 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">

<route id="_preview_error" path="/{code}.{_format}">
<default key="_controller">error_controller::preview</default>
<default key="_format">html</default>
<requirement key="code">\d+</requirement>
</route>
<import resource="errors.php" type="php" />
</routes>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?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.
*/

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

return function (RoutingConfigurator $routes): void {
$routes->add('_webhook_controller', '/{type}')
->controller('webhook_controller::handle')
->requirements(['type' => '.+'])
;
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">

<route id="_webhook_controller" path="/{type}">
<default key="_controller">webhook.controller::handle</default>
<requirement key="type">.+</requirement>
</route>
<import resource="webhook.php" type="php" />
</routes>
1 change: 1 addition & 0 deletions src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CHANGELOG
7.3
---

* Add `profiler.php` and `wdt.php` routing configuration files (use them instead of their XML equivalent)
* Add `ajax_replace` option for replacing toolbar on AJAX requests

7.2
Expand Down
6D40
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?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.
*/

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

return function (RoutingConfigurator $routes): void {
$routes->add('_profiler_home', '/')
->controller('web_profiler.controller.profiler::homeAction')
;
$routes->add('_profiler_search', '/search')
->controller('web_profiler.controller.profiler::searchAction')
;
$routes->add('_profiler_search_bar', '/search_bar')
->controller('web_profiler.controller.profiler::searchBarAction')
;
$routes->add('_profiler_phpinfo', '/phpinfo')
->controller('web_profiler.controller.profiler::phpinfoAction')
;
$routes->add('_profiler_xdebug', '/xdebug')
->controller('web_profiler.controller.profiler::xdebugAction')
;
$routes->add('_profiler_font', '/font/{fontName}.woff2')
->controller('web_profiler.controller.profiler::fontAction')
;
$routes->add('_profiler_search_results', '/{token}/search/results')
->controller('web_profiler.controller.profiler::searchResultsAction')
;
$routes->add('_profiler_open_file', '/open')
->controller('web_profiler.controller.profiler::openAction')
;
$routes->add('_profiler', '/{token}')
->controller('web_profiler.controller.profiler::panelAction')
;
$routes->add('_profiler_router', '/{token}/router')
->controller('web_profiler.controller.router::panelAction')
;
$routes->add('_profiler_exception', '/{token}/exception')
->controller('web_profiler.controller.exception_panel::body')
;
$routes->add('_profiler_exception_css', '/{token}/exception.css')
->controller('web_profiler.controller.exception_panel::stylesheet')
;
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,5 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">

<route id="_profiler_home" path="/">
<default key="_controller">web_profiler.controller.profiler::homeAction</default>
</route>

<route id="_profiler_search" path="/search">
<default key="_controller">web_profiler.controller.profiler::searchAction</default>
</route>

<route id="_profiler_search_bar" path="/search_bar">
<default key="_controller">web_profiler.controller.profiler::searchBarAction</default>
</route>

<route id="_profiler_phpinfo" path="/phpinfo">
<default key="_controller">web_profiler.controller.profiler::phpinfoAction</default>
</route>

<route id="_profiler_xdebug" path="/xdebug">
<default key="_controller">web_profiler.controller.profiler::xdebugAction</default>
</route>

<route id="_profiler_font" path="/font/{fontName}.woff2">
<default key="_controller">web_profiler.controller.profiler::fontAction</default>
</route>

<route id="_profiler_search_results" path="/{token}/search/results">
<default key="_controller">web_profiler.controller.profiler::searchResultsAction</default>
</route>

<route id="_profiler_open_file" path="/open">
<default key="_controller">web_profiler.controller.profiler::openAction</default>
</route>

<route id="_profiler" path="/{token}">
<default key="_controller">web_profiler.controller.profiler::panelAction</default>
</route>

<route id="_profiler_router" path="/{token}/router">
<default key="_controller">web_profiler.controller.router::panelAction</default>
</route>

<route id="_profiler_exception" path="/{token}/exception">
<default key="_controller">web_profiler.controller.exception_panel::body</default>
</route>

<route id="_profiler_exception_css" path="/{token}/exception.css">
<default key="_controller">web_profiler.controller.exception_panel::stylesheet</default>
</route>

<import resource="profiler.php" type="php" />
</routes>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?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.
*/

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

return function (RoutingConfigurator $routes): void {
$routes->add('_wdt_stylesheet', '/styles')
->controller('web_profiler.controller.profiler::toolbarStylesheetAction')
;
$routes->add('_wdt', '/{token}')
->controller('web_profiler.controller.profiler::toolbarAction')
;
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,5 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">

<route id="_wdt_stylesheet" path="/styles">
<default key="_controller">web_profiler.controller.profiler::toolbarStylesheetAction</default>
</route>

<route id="_wdt" path="/{token}">
<default key="_controller">web_profiler.controller.profiler::toolbarAction</default>
</route>
<import resource="wdt.php" type="php" />
</routes>
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public function registerBundles(): iterable

protected function configureRoutes(RoutingConfigurator $routes): void
{
$routes->import(__DIR__.'/../../Resources/config/routing/profiler.xml')->prefix('/_profiler');
$routes->import(__DIR__.'/../../Resources/config/routing/wdt.xml')->prefix('/_wdt');
$routes->import(__DIR__.'/../../Resources/config/routing/profiler.php')->prefix('/_profiler');
$routes->import(__DIR__.'/../../Resources/config/routing/wdt.php')->prefix('/_wdt');
$routes->add('_', '/')->controller('kernel::homepageController');
}

Expand Down
0