Connect WordPress to Bugsink
When WordPress hits an unhandled PHP exception, Bugsink shows you the error, the plugin or theme frame that raised it, and the request that reached the site.
This guide installs the Sentry for WordPress plugin, points it at Bugsink, and triggers one deliberate plugin failure. The integration uses the open-source Sentry PHP SDK and sends its events directly to your Bugsink project.
To follow along, create a Bugsink project and copy its DSN. The quickstart guide shows where to find it.
Install the plugin
Install and activate Sentry for WordPress with WP-CLI from your WordPress directory:
wp plugin install wp-sentry-integration --activatewp plugin install wp-sentry-integration --activate
You can install the same plugin from WordPress’s Plugins → Add New screen by searching for “Sentry for WordPress”. The plugin is maintained separately from the SDK it uses underneath.
Configure your DSN
The plugin reads its PHP DSN while WordPress loads wp-config.php. Add the
configuration before the final wp-settings.php include:
$bugsinkDsn = getenv('SENTRY_DSN'); if (is_string($bugsinkDsn) && $bugsinkDsn !== '') { define('WP_SENTRY_PHP_DSN', $bugsinkDsn); } define('WP_SENTRY_VERSION', 'inventory-wordpress@1.0.0');$bugsinkDsn = getenv('SENTRY_DSN'); if (is_string($bugsinkDsn) && $bugsinkDsn !== '') { define('WP_SENTRY_PHP_DSN', $bugsinkDsn); } define('WP_SENTRY_VERSION', 'inventory-wordpress@1.0.0');
Set SENTRY_DSN in the PHP process environment to the DSN from your Bugsink
project. WP_SENTRY_VERSION becomes the release on each event; replace the
example value with a version that identifies your deployed site code.
Trigger an unhandled exception
The plugin registers WordPress’s PHP error and exception handlers, so your application code does not need a Bugsink-specific call. To verify the setup, this small plugin raises an exception for a missing product:
add_action('template_redirect', static function (): void { $path = parse_url($_SERVER['REQUEST_URI'] ?? '', PHP_URL_PATH); if (!is_string($path) || !preg_match('#^/checkout/([^/]+)/?$#', $path, $matches)) { return; } $sku = sanitize_text_field(rawurldecode($matches[1])); throw new InventoryProductNotFound("Product {$sku} is not in inventory"); });add_action('template_redirect', static function (): void { $path = parse_url($_SERVER['REQUEST_URI'] ?? '', PHP_URL_PATH); if (!is_string($path) || !preg_match('#^/checkout/([^/]+)/?$#', $path, $matches)) { return; } $sku = sanitize_text_field(rawurldecode($matches[1])); throw new InventoryProductNotFound("Product {$sku} is not in inventory"); });
Start the site with the DSN in its environment, then request a product that does not exist:
export SENTRY_DSN=https://key@bugsink.example/1 php -S 127.0.0.1:8000 -t wordpress wordpress/index.php :::bash curl http://127.0.0.1:8000/checkout/wordpress-missing/export SENTRY_DSN=https://key@bugsink.example/1 php -S 127.0.0.1:8000 -t wordpress wordpress/index.php :::bash curl http://127.0.0.1:8000/checkout/wordpress-missing/
WordPress returns HTTP 500. The reporting plugin sends the exception before PHP finishes handling the failed request.
See the error in Bugsink
Open your Bugsink project and select the new InventoryProductNotFound issue.
Its event points to the application plugin and includes the checkout request,
WordPress version, active plugins, and configured release.
InventoryProductNotFound
That’s it: unhandled WordPress PHP exceptions will now be reported to Bugsink.
For handled exceptions, messages, logging, and extra context, continue with the PHP guide.
