Platform.sh supports Blackfire.io.
Blackfire is a PHP profiler and automated performance testing tool that can be used in the development Integration, Staging, and Production environments.
It grants details information on your PHP code's resources consumption across Wall-Time, CPU, I/O, Memory, Network Calls, HTTP requests and SQL queries.
In addition, it can profile your code automatically and notify you whenever your code does not comply with best practices for PHP, Symfony, Drupal, eZPlatform, Typo3 & Magento code performance management.
For a high level overview and demo of Blackfire, check out the full video tutorial.
Check the latest versions of the probe and CLI tool on Blackfire's documentation.
Blackfire also offers a perpetually-free edition but it is for local development only and will not run on Platform.sh.
Go to your Dashboard and create a new environment under the Environments tab.
You will need to store the server credentials for further configuration. You can find them any time under the "Settings" tab of your environment in Blackfire.
Configure the extension in your
.platform.app.yaml as follows:
runtime: extensions: - blackfire
Push the changes to your Platform environment to enable Blackfire as follows:
git add .platform.app.yaml git commit -m "Enable Blackfire." git push
Blackfire enables to have a fine grained configuration of server credentials across branches and environments on Platform.sh.
Configuring server credentials on your master branch will enable you to make sure you can profile any other branch:
platform variable:create -e master env:BLACKFIRE_SERVER_ID <insert your Server ID> platform variable:create -e master env:BLACKFIRE_SERVER_TOKEN <insert your Server Token>
A recommendation is to have a Blackfire environment for production, another one for staging, and another one for development/integration. That can be mapped in Platform.sh to one Blackfire environment for the production branch, one for the staging branch, and one for all feature branches.
platform variable:create -e=<insert your branch name> env:BLACKFIRE_SERVER_ID <insert your Server ID> platform variable:create -e=<insert your branch name> env:BLACKFIRE_SERVER_TOKEN <insert your Server Token>
Login via SSH to your container and confirm that Blackfire is running as follows:
php --ri blackfire blackfire blackfire => enabled blackfire => 1.16.1 Timing measurement => gtod Num of CPU => 8 ...
Access your site via your browser and click
Profile in the Blackfire Companion.
That's it! Your site will be profiled and you should get all the results in your Blackfire account.
Blackfire also enables to:
- collaborate with the rest of your team
- write performance tests
- automate profiling with periodic builds
- integrate further with Platform.sh by enabling to automate profiling as each code commit
- integrate with New Relic for combined benefits of monitoring and profiling
- integrate with GitHub, Bitbucket and GitLab to show the results of Blackfire builds at the commit status level
Check Blackfire's documentation for more information.
Those features may require a Premium or an Enterprise subscription. We offer attractive bundles of Platform.sh and Blackfire.io subscriptions. Please contact our sales department to discuss how we can help you.
If you are using one of those, you will need them to let Blackfire access your servers. More information on how to configure a bypass.
If you are using the HTTP cache with cookies , please update in your
.platform.app.yaml the cookies that are allowed to go through the cache. You need to allow the
__blackfire cookie name.
cache: enabled: true cookies: ["/SESS.*/", "__blackfire"]
If the above didn't help, collect the following and send it to the Blackfire support:
- The output of
platform ssh -- php -d display_startup_errors=on --ri blackfirecommand
- The Blackfire logs
Please execute the following in the environment where you're facing the issue:
platform variable:create php:blackfire.log_file /tmp/blackfire.log
platform variable:create php:blackfire.log_level 4
- start a profile/build again
You will get the logs with
platform ssh -- cat /tmp/blackfire.log > blackfire.log.
Once you are done, please disable logging with:
platform variable:delete php:blackfire.log_file
platform variable:delete php:blackfire.log_level