Skip to content

Blackfire.io

Blackfire.io is a paid PHP profiling tool. Unlike XDebug, it can be left on without impacting site performance. It is also considered easier to use than XDebug for performance checks. However, it cannot act as powerful a debugger as XDebug.

NOTE: XDebug and Blackfire can never be used together.

  1. Log into a Blackfire.io account.
  2. Set up an environment or profile to obtain a Server ID and Server Token. To get started, first make sure you have an account with Blackfire.io. Set up an environment or profile so that you have a Server ID and Server Token.
  3. Go to the PHP > Blackfire Admin panel.
  4. Enter the information as indicated.

config-75

Using the Chrome or Firefox browser extensions, start profiling the Stratus site direct from a browser.

Update Varnish

In order for Blackfire to run with Varnish (if enabled), the following code needs to be added to Varnish VCL inside the sub vcl_rcv function:

if (req.esi_level > 0) {
    # ESI request should not be included in the profile.
    # Instead you should profile them separately, each one
    # in their dedicated profile.
    # Removing the Blackfire header avoids to trigger the profiling.
    # Not returning let it go trough your usual workflow as a regular
    # ESI request without distinction.

    unset req.http.X-Blackfire-Query;
}

# If it's a Blackfire query and the client is authorized
# just pass directly to the application.

if (req.http.X-Blackfire-Query) {
    return (pass);
}