DDEV

DDEV is a development platform for PHP based on Docker containers (DDEV-Local), and a cloud based hosting (DDEV-Live).

DDEV-Local

Blackfire probe is installed out-of-the-box for every project configured to work with DDEV. The agent must however be properly enabled and configured.

DDEV being based on Docker, it supports custom docker-compose YAML files for adding services. As such, the best way to enable Blackfire in DDEV projects is to add the official Docker image for the agent.

  1. At the root of your DDEV project, create a docker-compose.blackfire.yaml under the .ddev/ folder:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    version: '3.6'
    services:
      blackfire:
        container_name: ddev-${DDEV_SITENAME}-blackfire
        image: blackfire/blackfire
        ports: ['8707']
        environment:
          # Replace the values by your credentials.
          BLACKFIRE_SERVER_ID: '<YOUR_SERVER_ID>'
          BLACKFIRE_SERVER_TOKEN: '<YOUR_SERVER_TOKEN>'
          BLACKFIRE_CLIENT_ID: '<YOUR_CLIENT_ID>'
          BLACKFIRE_CLIENT_TOKEN: '<YOUR_CLIENT_TOKEN>'
        hostname: ${DDEV_SITENAME}-blackfire
      web:
        links:
          - blackfire:blackfire
    
  2. Create a blackfire.ini file under the .ddev/php/:

    1
    2
    3
    4
    5
    6
    7
    blackfire.agent_socket = tcp://blackfire:8707
    
    ; Log verbosity level (4: debug, 3: info, 2: warning, 1: error)
    ;blackfire.log_level = 1
    
    ; Log file (STDERR by default)
    ;blackfire.log_file = /tmp/blackfire.log
    
  3. Restart ddev with ddev restart command.

Note

Additional documentation is provided by ddev-contrib.