Skip to content
  1. Blog

Better WordPress Debugging with Acorn

Ben Word Ben Word on

WordPress has a debug mode, WP_DEBUG, that is enabled by setting the WP_DEBUG constant in your configuration file. WP_DEBUG should always be enabled in your local development environments in order to quickly catch notices and errors.

For folks using Bedrock, the modern WordPress boilerplate with Composer, WP_DEBUG is already enabled by default on development environments.

WP_DEBUG default output

The default WP_DEBUG output isn’t great: it simply shows the error messages and notices directly on the screen. This is absolutely better than nothing, and if you are developing WordPress plugins and themes, you should always enable WP_DEBUG mode. The WordPress ecosystem is littered with countless plugins and themes that emit notices and errors.

Screenshot of the default WP_DEBUG output

Acorn WP_DEBUG outputs

Acorn’s WP_DEBUG default

Acorn will enhance your WP_DEBUG output when WP_DEBUG && WP_DEBUG_DISPLAY are enabled. By default, Acorn utilizes the Symfony exception handler. This provides an easier to read exceptions thrown on your sites.

Screenshot of Acorn's default WP_DEBUG output

Acorn’s WP_DEBUG output with Ignition

If you’re a Laravel developer, you might be familiar with Ignition — the default error page for Laravel since Laravel v9. With the release of Acorn v3, Acorn now includes support for routing in Laravel, which also means that Ignition is now supported on WordPress sites using Acorn. We recommend installing Ignition on your sites for the best error handling experience in WordPress.

Screenshot of Acorn's WP_DEBUG output with Ignition

To start using Ignition with WordPress, run composer require spatie/laravel-ignition --dev from the same directory that Acorn’s installed.

Acorn’s WP_DEBUG output with whoops

Prior to Acorn v3, we recommended installing whoops alongside Acorn. For folks still on Acorn v2, we do recommend upgrading to Acorn v3, but it’s still possible to have a better experience compared to the Symfony error page by installing whoops:

Screenshot of Acorn's WP_DEBUG output with whoops

Non-Acorn alternatives

If you’re not developing a site with Acorn (which you should be — don’t you want to use things like Laravel helpers in your codebase for a more modern PHP vibe?)— there’s also some WordPress plugins that provide a better WP_DEBUG experience besides the default:

Discuss this post on Roots Discourse

About the author

Ben Word

Ben Word has been creating WordPress sites since 2004. He loves dogs, climbing, and yoga, and is passionate about helping people build awesome things on the web.

Subscribe for updates

Join over 8,000 subscribers on our newsletter to get the latest Roots updates and tips on building better WordPress sites

Looking for WordPress plugin recommendations, the newest modern WordPress projects, and general web development tips and articles?