How do I debug a Drupal site?

Install Xdebug and configure your IDE to listen for connections. PhpStorm and VS Code both support Xdebug well. Set breakpoints in your code, trigger the request, and step through execution to see variable values and call stacks.

For quick debugging without an IDE, the Devel and Kint modules give you functions like kint and dpm that dump variables into the page in a readable format.

Logging is also useful. Use the logger service to write messages to the Drupal log, which you can view at Reports then Recent log messages. Enable Twig debugging to see which templates are being used. For database queries, the Devel module’s Query Log shows exactly what Drupal is running. Combining these tools gives you visibility into almost any part of a Drupal request.

Facebook
Twitter
LinkedIn
Pinterest