diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6d2f8eb5..5e5e8db3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,39 @@
CHANGELOG
=========
+7.3
+---
+
+ * Add `profiler.php` and `wdt.php` routing configuration files (use them instead of their XML equivalent)
+
+ 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
+ ```
+
+ * Add `ajax_replace` option for replacing toolbar on AJAX requests
+
7.2
---
@@ -65,7 +98,7 @@ CHANGELOG
-----
* added information about orphaned events
- * made the toolbar auto-update with info from ajax reponses when they set the
+ * made the toolbar auto-update with info from ajax responses when they set the
`Symfony-Debug-Toolbar-Replace header` to `1`
4.0.0
diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php
index 51ddad76..649bf459 100644
--- a/DependencyInjection/Configuration.php
+++ b/DependencyInjection/Configuration.php
@@ -31,9 +31,20 @@ public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('web_profiler');
- $treeBuilder->getRootNode()
+ $treeBuilder
+ ->getRootNode()
+ ->docUrl('https://symfony.com/doc/{version:major}.{version:minor}/reference/configuration/web_profiler.html', 'symfony/web-profiler-bundle')
->children()
- ->booleanNode('toolbar')->defaultFalse()->end()
+ ->arrayNode('toolbar')
+ ->info('Profiler toolbar configuration')
+ ->canBeEnabled()
+ ->children()
+ ->booleanNode('ajax_replace')
+ ->defaultFalse()
+ ->info('Replace toolbar on AJAX requests')
+ ->end()
+ ->end()
+ ->end()
->booleanNode('intercept_redirects')->defaultFalse()->end()
->scalarNode('excluded_ajax_paths')->defaultValue('^/((index|app(_[\w]+)?)\.php/)?_wdt')->end()
->end()
diff --git a/DependencyInjection/WebProfilerExtension.php b/DependencyInjection/WebProfilerExtension.php
index 6ad6982c..d1867029 100644
--- a/DependencyInjection/WebProfilerExtension.php
+++ b/DependencyInjection/WebProfilerExtension.php
@@ -46,11 +46,12 @@ public function load(array $configs, ContainerBuilder $container): void
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('profiler.php');
- if ($config['toolbar'] || $config['intercept_redirects']) {
+ if ($config['toolbar']['enabled'] || $config['intercept_redirects']) {
$loader->load('toolbar.php');
$container->getDefinition('web_profiler.debug_toolbar')->replaceArgument(4, $config['excluded_ajax_paths']);
+ $container->getDefinition('web_profiler.debug_toolbar')->replaceArgument(7, $config['toolbar']['ajax_replace']);
$container->setParameter('web_profiler.debug_toolbar.intercept_redirects', $config['intercept_redirects']);
- $container->setParameter('web_profiler.debug_toolbar.mode', $config['toolbar'] ? WebDebugToolbarListener::ENABLED : WebDebugToolbarListener::DISABLED);
+ $container->setParameter('web_profiler.debug_toolbar.mode', $config['toolbar']['enabled'] ? WebDebugToolbarListener::ENABLED : WebDebugToolbarListener::DISABLED);
}
$container->getDefinition('debug.file_link_formatter')
diff --git a/EventListener/WebDebugToolbarListener.php b/EventListener/WebDebugToolbarListener.php
index c51cf309..2ad19250 100644
--- a/EventListener/WebDebugToolbarListener.php
+++ b/EventListener/WebDebugToolbarListener.php
@@ -48,6 +48,7 @@ public function __construct(
private string $excludedAjaxPaths = '^/bundles|^/_wdt',
private ?ContentSecurityPolicyHandler $cspHandler = null,
private ?DumpDataCollector $dumpDataCollector = null,
+ private bool $ajaxReplace = false,
) {
}
@@ -96,6 +97,10 @@ public function onKernelResponse(ResponseEvent $event): void
// do not capture redirects or modify XML HTTP Requests
if ($request->isXmlHttpRequest()) {
+ if (self::ENABLED === $this->mode && $this->ajaxReplace && !$response->headers->has('Symfony-Debug-Toolbar-Replace')) {
+ $response->headers->set('Symfony-Debug-Toolbar-Replace', '1');
+ }
+
return;
}
diff --git a/Resources/config/routing/profiler.php b/Resources/config/routing/profiler.php
new file mode 100644
index 00000000..46175d1d
--- /dev/null
+++ b/Resources/config/routing/profiler.php
@@ -0,0 +1,62 @@
+
+ *
+ * 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;
+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')
+ ;
+ $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')
+ ;
+};
diff --git a/Resources/config/routing/profiler.xml b/Resources/config/routing/profiler.xml
index 363b15d8..8712f387 100644
--- a/Resources/config/routing/profiler.xml
+++ b/Resources/config/routing/profiler.xml
@@ -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">
-
Message ID | +Value | +
---|---|
{{ id }} | +{{ profiler_dump(value) }} | +