Using Blackfire Profiler service to profile your PHP applications.
Register with blackfire.io.
Open Blackfire Account Credentials to find your API keys.
Option 1
With this option, the API keys are stored on your host and not exposed in the project’s codebase.
fin config set --global BLACKFIRE_CLIENT_ID=<blackfire-client-id>
fin config set --global BLACKFIRE_CLIENT_TOKEN=<blackfire-client-token>
fin config set --global BLACKFIRE_SERVER_ID=<blackfire-server-id>
fin config set --global BLACKFIRE_SERVER_TOKEN=<blackfire-server-token>
Note: The values will be stored in $HOME/.docksal/docksal.env on your host.
Option 2
With this option, the API keys are stored in the project’s codebase.
fin config set BLACKFIRE_CLIENT_ID=<blackfire-client-id>
fin config set BLACKFIRE_CLIENT_TOKEN=<blackfire-client-token>
fin config set BLACKFIRE_SERVER_ID=<blackfire-server-id>
fin config set BLACKFIRE_SERVER_TOKEN=<blackfire-server-token>
Note: The values will be stored in .docksal/docksal.env in the project’s codebase.
Add the blackfire service under the services section in .docksal/docksal.yml:
services:
...
  # Blackfire
  blackfire:
    extends:
      file: ${HOME}/.docksal/stacks/services.yml
      service: blackfire
...
Apply new configuration with fin project start (fin p start).
Follow the instructions to install and use blackfire via the Chrome extension.
See blackfire.io for more docs on using blackfire; including support for other browsers.
Use fin exec blackfire run <command> from host or blackfire run <command> within cli to profile cli commands.
Example:
$ fin exec blackfire run drush version
 Drush Version   :  8.1.11 
Blackfire Run completed
Graph URL https://blackfire.io/profiles/xxxxxxxxxx/graph
No tests! Create some now https://blackfire.io/docs/cookbooks/tests
No recommendations
Wall Time     323ms
CPU Time        n/a
I/O Time        n/a
Memory       8.56MB
Network         n/a     n/a     n/a
SQL             n/a     n/a
For additional information and examples see Blackfire’s official documentation: Profiling CLI Commands.