8000 Add PHP config support for routing · symfony/symfony@c8b8b19 · GitHub
[go: up one dir, main page]

Skip to content

Commit c8b8b19

Browse files
committed
Add PHP config support for routing
1 parent ed7dba6 commit c8b8b19

File tree

10 files changed

+117
-64
lines changed

10 files changed

+117
-64
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
7.3
55
---
66

7+
* Add `errors.php` and `webhook.php` routing configuration files (use them instead of the XML equivalent)
78
* Add support for the ObjectMapper component
89
* Add support for assets pre-compression
910
* Rename `TranslationUpdateCommand` to `TranslationExtractCommand`
Lines changed: 20 additions & 0 deletions
Origi 8000 nal file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
13+
14+
return function (RoutingConfigurator $routes): void {
15+
$routes->add('_preview_error', '/{code}.{_format}')
16+
->controller(['@error_controller', 'preview'])
17+
->defaults(['_format' => 'html'])
18+
->requirements(['code' => '\d+'])
19+
;
20+
};

src/Symfony/Bundle/FrameworkBundle/Resources/config/routing/errors.xml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,5 @@
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">
66

7-
<route id="_preview_error" path="/{code}.{_format}">
8-
<default key="_controller">error_controller::preview</default>
9-
<default key="_format">html</default>
10-
<requirement key="code">\d+</requirement>
11-
</route>
7+
<import resource="errors.php" type="php" />
128
</routes>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
13+
14+
return function (RoutingConfigurator $routes): void {
15+
$routes->add('_webhook_controller', '/{type}')
16+
->controller(['@webhook_controller', 'handle'])
17+
->requirements(['type' => '.+'])
18+
;
19+
};

src/Symfony/Bundle/FrameworkBundle/Resources/config/routing/webhook.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,5 @@
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">
66

7-
<route id="_webhook_controller" path="/{type}">
8-
<default key="_controller">webhook.controller::handle</default>
9-
<requirement key="type">.+</requirement>
10-
</route>
7+
<import resource="webhook.php" type="php" />
118
</routes>

src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
7.3
55
---
66

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

910
7.2
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
13+
14+
return function (RoutingConfigurator $routes): void {
15+
$routes->add('_profiler_home', '/')
16+
->controller(['@web_profiler.controller.profiler', 'homeAction'])
17+
;
18+
$routes->add('_profiler_search', '/search')
19+
->controller(['@web_profiler.controller.profiler', 'searchAction'])
20+
;
21+
$routes->add('_profiler_search_bar', '/search_bar')
22+
->controller(['@web_profiler.controller.profiler', 'searchBarAction'])
23+
;
24+
$routes->add('_profiler_phpinfo', '/phpinfo')
25+
->controller(['@web_profiler.controller.profiler', 'phpinfoAction'])
26+
;
27+
$routes->add('_profiler_xdebug', '/xdebug')
28+
->controller(['@web_profiler.controller.profiler', 'xdebugAction'])
29+
;
30+
$routes->add('_profiler_font', '/font/{fontName}.woff2')
31+
->controller(['@web_profiler.controller.profiler', 'fontAction'])
32+
;
33+
$routes->add('_profiler_search_results', '/{token}/search/results')
34+
->controller(['@web_profiler.controller.profiler', 'searchResultsAction'])
35+
;
36+
$routes->add('_profiler_open_file', '/open')
37+
->controller(['@web_profiler.controller.profiler', 'openAction'])
38+
;
39+
$routes->add('_profiler', '/{token}')
40+
->controller(['@web_profiler.controller.profiler', 'panelAction'])
41+
;
42+
$routes->add('_profiler_router', '/{token}/router')
43+
->controller(['@web_profiler.controller.router', 'panelAction'])
44+
;
45+
$routes->add('_profiler_exception', '/{token}/exception')
46+
->controller(['@web_profiler.controller.exception_panel', 'body'])
47+
;
48+
$routes->add('_profiler_exception_css', '/{token}/exception.css')
49+
->controller(['@web_profiler.controller.exception_panel', 'stylesheet'])
50+
;
51+
};

src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/profiler.xml

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,5 @@
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">
66

7-
<route id="_profiler_home" path="/">
8-
<default key="_controller">web_profiler.controller.profiler::homeAction</default>
9-
</route>
10-
11-
<route id="_profiler_search" path="/search">
12-
<default key="_controller">web_profiler.controller.profiler::searchAction</default>
13-
</route>
14-
15-
<route id="_profiler_search_bar" path="/search_bar">
16-
<default key="_controller">web_profiler.controller.profiler::searchBarAction</default>
17-
</route>
18-
19-
<route id="_profiler_phpinfo" path="/phpinfo">
20-
<default key="_controller">web_profiler.controller.profiler::phpinfoAction</default>
21-
</route>
22-
23-
<route id="_profiler_xdebug" path="/xdebug">
24-
<default key="_controller">web_profiler.controller.profiler::xdebugAction</default>
25-
</route>
26-
27-
<route id="_profiler_font" path="/font/{fontName}.woff2">
28-
<default key="_controller">web_profiler.controller.profiler::fontAction</default>
29-
</route>
30-
31-
<route id="_profiler F987 _search_results" path="/{token}/search/results">
32-
<default key="_controller">web_profiler.controller.profiler::searchResultsAction</default>
33-
</route>
34-
35-
<route id="_profiler_open_file" path="/open">
36-
<default key="_controller">web_profiler.controller.profiler::openAction</default>
37-
</route>
38-
39-
<route id="_profiler" path="/{token}">
40-
<default key="_controller">web_profiler.controller.profiler::panelAction</default>
41-
</route>
42-
43-
<route id="_profiler_router" path="/{token}/router">
44-
<default key="_controller">web_profiler.controller.router::panelAction</default>
45-
</route>
46-
47-
<route id="_profiler_exception" path="/{token}/exception">
48-
<default key="_controller">web_profiler.controller.exception_panel::body</default>
49-
</route>
50-
51-
<route id="_profiler_exception_css" path="/{token}/exception.css">
52-
<default key="_controller">web_profiler.controller.exception_panel::stylesheet</default>
53-
</route>
54-
7+
<import resource="profiler.php" type="php" />
558
</routes>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
13+
14+
return function (RoutingConfigurator $routes): void {
15+
$routes->add('_wdt_stylesheet', '/styles')
16+
->controller(['@web_profiler.controller.profiler', 'toolbarStylesheetAction'])
17+
;
18+
$routes->add('_wdt', '/{token}')
19+
->controller(['@web_profiler.controller.profiler', 'toolbarAction'])
20+
;
21+
};

src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/wdt.xml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,5 @@
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">
66

7-
<route id="_wdt_stylesheet" path="/styles">
8-
<default key="_controller">web_profiler.controller.profiler::toolbarStylesheetAction</default>
9-
</route>
10-
11-
<route id="_wdt" path="/{token}">
12-
<default key="_controller">web_profiler.controller.profiler::toolbarAction</default>
13-
</route>
7+
<import resource="wdt.php" type="php" />
148
</routes>

0 commit comments

Comments
 (0)
0