Skip to content

Commit 7f8f92f

Browse files
toby-griffithsdunglas
authored andcommitted
Details on how to set up Blackfire.io profiling (#635)
* Details on how to set up Blackfire.io profiling * Update performance.md * Update performance.md
1 parent 26c88ed commit 7f8f92f

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

core/performance.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,47 @@ api_platform:
264264
```
265265

266266
More details are available on the [pagination documentation](pagination.md#partial-pagination).
267+
268+
## Profiling with Blackfire.io
269+
270+
Blackfire.io allows you to monitor the performance of your applications. For more information, visit the [Blackfire.io website](https://blackfire.io/).
271+
272+
To configure Blackfire.io follow these simple steps:
273+
274+
1. Add the following to your `docker-compose.yml` file (or an [override file](https://docs.docker.com/compose/reference/overview/#specifying-multiple-compose-files), if only to be used in development)
275+
276+
```yaml
277+
blackfire:
278+
image: blackfire/blackfire
279+
environment:
280+
# Exposes the host BLACKFIRE_SERVER_ID and TOKEN environment variables.
281+
- BLACKFIRE_SERVER_ID
282+
- BLACKFIRE_SERVER_TOKEN
283+
```
284+
285+
2. Add your Blackfire.io id and server token to your `.env` file at the root of your project (be sure not to commit this to a public repository)
286+
287+
BLACKFIRE_SERVER_ID=xxxxxxxxxx
288+
BLACKFIRE_SERVER_TOKEN=xxxxxxxxxx
289+
290+
or set it in the console before running Docker commands
291+
292+
$ export BLACKFIRE_SERVER_ID=xxxxxxxxxx
293+
$ export BLACKFIRE_SERVER_TOKEN=xxxxxxxxxx
294+
295+
3. Install and configure the Blackfire probe in the app container, by adding the following to your `./Dockerfile`
296+
297+
```dockerfile
298+
RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
299+
&& curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/alpine/amd64/$version \
300+
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp \
301+
&& mv /tmp/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \
302+
&& printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini
303+
```
304+
305+
4. Rebuild and restart all your containers
306+
307+
$ docker-compose build
308+
$ docker-compose up -d
309+
310+
For details on how to perform profiling, see [the Blackfire.io documentation](https://blackfire.io/docs/integrations/docker#using-the-client-for-http-profiling).

0 commit comments

Comments
 (0)