DDEV

DDEV is a development platform for PHP based on Docker containers (DDEV-Local).

DDEV-Local

You must use version 1.17 or above of DDEV-local. Their documentation offers detailed procedures for most OSes.

Configuration

The Blackfire probe is installed by default and the agent is added as an additional service. It can be configured globally with this command:

or to display your Blackfire's credentials.

ddev config global \
    --web-environment="BLACKFIRE_SERVER_ID=<YOUR_BLACKFIRE_SERVER_ID>,\
        BLACKFIRE_SERVER_TOKEN=<YOUR_BLACKFIRE_SERVER_TOKEN>,\
        BLACKFIRE_CLIENT_ID=<YOUR_BLACKFIRE_CLIENT_ID>,\
        BLACKFIRE_CLIENT_TOKEN=<YOUR_BLACKFIRE_CLIENT_TOKEN>"

The credentials can be configured for a specific project by updating its DDEV config file located in .ddev/config.yaml:

or to display your Blackfire's credentials.

web_environment:
    - BLACKFIRE_SERVER_ID=<YOUR_BLACKFIRE_SERVER_ID>
    - BLACKFIRE_SERVER_TOKEN=<YOUR_BLACKFIRE_SERVER_TOKEN>
    - BLACKFIRE_CLIENT_ID=<YOUR_BLACKFIRE_CLIENT_ID>
    - BLACKFIRE_CLIENT_TOKEN=<YOUR_BLACKFIRE_CLIENT_TOKEN>

Restart DDEV

1
ddev restart

Activate Blackfire

To activate Blackfire after every ddev restart, run the following command:

1
ddev blackfire

To activate Blackfire every time your project starts, in the .ddev/confiy.yml file of your DDEV project, define a custom hook similar to:

1
2
3
4
5
# .ddev/config.yml

hooks:
    post-start:
        - exec-host: 'ddev blackfire'

Additional commands:

  • Disable the Blackfire Probe and stops the Blackfire agent (this can be useful if you need to run xdebug, which is deactivated when you start Blackfire with ddev blackfire):
1
ddev blackfire off
  • Verify if Blackfire is currently enabled, as well as the currently installed: Blackfire Probe version.
1
ddev blackfire status

You can now profile requests with all available methods. When profiling with the CLI, prefix the blackfire commands with ddev exec:

  • ddev exec blackfire curl https://foobar.ddev.site
  • ddev exec blackfire drush st

Note

When using ddev exec blackfire curl http://127.0.0.1, there is no need to specify a DDEV external port as you are already executing it in a DDEV context. Additional documentation is provided by ddev-contrib.