WebProfiler
Drupal development profiler that extracts, collects, stores, and displays detailed profiling information for every request.
webprofiler
Install
composer require 'drupal/webprofiler:^11.1'
composer require 'drupal/webprofiler:^10.3'
Overview
WebProfiler is a comprehensive development profiling tool for Drupal 11 that provides deep insights into every request processed by your Drupal application. It collects detailed profiling data including database queries, cache operations, memory usage, HTTP requests, form processing, views rendering, and more.
The module creates a profile file for every request containing all collected information, which is then rendered on an interactive toolbar displayed at the bottom of every HTML response. A dedicated back-office dashboard provides detailed analysis of each profile.
WebProfiler wraps and decorates many Drupal core subsystems to intercept and record their operations, giving developers unprecedented visibility into application performance. Features include database query analysis with slow query highlighting, cache hit/miss tracking, Twig template profiling, event listener monitoring, and Core Web Vitals measurement.
Important: WebProfiler must not be used in production environments as it replaces core Drupal subsystems which can lead to performance issues.
Features
- Interactive toolbar displayed at the bottom of every page showing key metrics at a glance
- Comprehensive dashboard for detailed profile analysis with multiple data collector panels
- Database query profiling with execution time tracking, slow query highlighting, and query source identification
- Cache hit/miss monitoring across all cache bins with detailed CID and tag information
- Memory usage tracking showing peak memory consumption and memory limits
- Request/response analysis including headers, cookies, session data, GET/POST parameters, and BigPipe placeholders
- Time metrics collection using Symfony Stopwatch for detailed performance breakdown
- User session information including authentication provider, roles, and user details
- Views rendering profiler showing build, execute, and render times with direct edit links
- Forms data collector displaying all form elements, their types, and access status
- Block tracking for both loaded and rendered blocks with region and plugin information
- Service container analysis showing all registered services, their initialization status, and middlewares
- Event dispatcher monitoring showing called and not-called event listeners with priorities
- Asset profiling for CSS, JavaScript, and Drupal libraries used on each page
- Theme data collector with Twig profiling, filter/function listings, and rendering call graph visualization
- SDC (Single Directory Components) tracking with component metadata and documentation
- HTTP client monitoring for outgoing requests with request/response details and timing
- Mail system profiling showing all sent emails with plugin information
- Routing collector displaying all registered routes with their controllers
- Extension monitoring showing all active modules and themes
- Configuration and State API tracking
- Translation string monitoring for both translated and untranslated strings
- Frontend performance data collection including Core Web Vitals (LCP, FID, CLS)
- Redirect interception for easier debugging of redirect chains
- IDE integration with clickable file links for PHPStorm, VS Code, Sublime, and other editors
- Drush command for exporting database query data to CSV format
- Custom error handler with detailed exception rendering (can be disabled)
- Profile storage with configurable location and automatic purging on cache clear
Use Cases
Debugging Slow Page Loads
Use the Time panel to identify which parts of the request are taking the longest. Enable the StopwatchTracer in settings.php to see detailed timing breakdowns. Check the Database panel for slow queries (highlighted based on threshold) and identify N+1 query problems by examining query counts and sources.
Optimizing Database Queries
The Database panel shows all queries executed during a request with execution times, caller information, and the ability to run EXPLAIN on queries. Sort by duration to find the slowest queries. Export query data using Drush for offline analysis or team review.
Analyzing Cache Efficiency
The Cache panel shows cache hits and misses across all cache bins. Identify cache items being requested multiple times (indicating potential optimization opportunities) and track which cache tags are being used.
Debugging Forms
The Forms panel displays all forms rendered on a page including their elements, types, and access status. Useful for understanding form structure and debugging access control issues.
Profiling Views Performance
The Views panel shows build, execute, and render times for each view displayed on the page. Direct edit links make it easy to jump to Views configuration for optimization.
Tracking External HTTP Requests
The HTTP panel monitors all outgoing HTTP client requests, showing request/response details and timing. Essential for debugging API integrations and identifying slow external dependencies.
Theme and Template Debugging
The Theme panel provides Twig profiling with a rendering call graph showing exactly which templates were rendered and in what order. Lists all available Twig filters, functions, and globals.
Monitoring Mail Delivery
The Mail panel captures all emails sent during a request, showing the mail plugin used, recipients, and message content. Invaluable for debugging email-related functionality.
Frontend Performance Analysis
The Frontend panel collects browser-side performance data including Navigation Timing API metrics and Core Web Vitals (LCP, FID, CLS). Essential for understanding real user experience.
Service Container Analysis
The Services panel shows all registered services with their initialization status, helping identify services that are instantiated unnecessarily or understanding the dependency injection container.
Tips
- Use the toolbar to quickly identify performance issues - look for high query counts, long execution times, or excessive cache misses
- Export database queries to CSV for complex analysis or to share with database administrators
- Configure IDE integration to click directly from stack traces to source code in your editor
- Enable intercept redirects when debugging redirect chains or authentication flows
- Use the Services panel to identify services that are being instantiated but may not be needed
- The Theme panel's Twig call graph helps understand template inheritance and rendering order
- Check the Events panel to see which event listeners are actually being called vs registered but unused
- Frontend panel requires JavaScript execution - check browser console if data isn't appearing
- Profile tokens can be bookmarked or shared for collaborative debugging
- Use path exclusions to reduce profiling overhead on AJAX endpoints you don't need to debug
Technical Details
Admin Pages 3
/admin/config/development/devel/webprofiler
Configure WebProfiler behavior including which data collectors to display in the toolbar, database query settings, IDE integration, and profile management.
/admin/reports/profiler/list
View a list of all saved profiles. Filter profiles by IP address, URL, HTTP method, and limit the number of results. Click on a profile token to view detailed information in the dashboard.
/admin/reports/profiler/view/{token}
Detailed dashboard view for a specific profile. Shows comprehensive information collected by all active data collectors organized in panels. Each panel provides deep insights into different aspects of the request.
Permissions 2
Drush Commands 1
drush webprofiler:export-database-data
Exports database query data from a profile to a CSV file. Useful for analyzing queries outside of the dashboard or sharing with team members.
Troubleshooting 7
Ensure the user has the 'view webprofiler toolbar' permission. Check if the current path is in the 'Exclude toolbar' or 'Exclude paths' settings. The toolbar only appears on HTML responses.
Add $settings['tracer_plugin'] = \Drupal\webprofiler\Plugin\Tracer\StopwatchTracer::class; to your settings.php file and clear cache.
WebProfiler uses a custom error handler. If you have another error handler (like Ignition), add $settings['webprofiler_error_page_disabled'] = TRUE; to settings.php.
Enable 'Purge on cache clear' in settings, or manually purge profiles from the settings page. Consider reducing the profile retention if disk space is a concern.
Adjust the 'Number of queries after which detailed output is disabled' setting to a lower value. This prevents rendering thousands of query details which can slow the browser.
Add this to your services.yml: parameters: webprofiler.file_profiler_storage_dns: 'file:/tmp/profiler'
Configure the IDE setting to match your editor. If using remote development, configure the remote and local path mappings to translate server paths to local paths.
Security Notes 6
- WebProfiler should NEVER be enabled on production sites as it exposes detailed internal application information
- The 'access webprofiler' permission should be restricted to trusted developers only
- Profile files may contain sensitive information including POST data, cookies, and session information
- Database query logs may expose sensitive data in query parameters
- Consider using path exclusions to prevent profiling of sensitive endpoints
- Profiles are stored in the public files directory by default - consider moving to a non-web-accessible location in shared environments