docs.blackfire.io

  1. Documentation
  2. Blackfire for PHP
  3. Integrations
  4. FrankenPHP

FrankenPHP beta

PHP

FrankenPHP support is in beta and not yet feature-complete.

FrankenPHP is a modern application server for PHP built on top of the Caddy webserver

Coverage

Manual Installation

FrankenPHP requires a ZTS (Zend Thread Safety) build of the Blackfire PHP Probe, which you can install by following our installation guides.

Docker

Alternatively, you can use the FrankenPHP base Docker image:

1
2
3
4
5
6
7
8
9
10
11

Loading...

Deterministic Profiling

Laravel Octane users: our integration supports Deterministic Profiling out of the box.

Symfony Runtime users: our integration also supports Deterministic Profiling out of the box.

If you are not using Laravel Octane or Symfony Runtime, update your FrankenPHP worker script to control the instrumentation manually:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
ignore_user_abort(true);
$handler = static function () {
    echo 'Hello Blackfire!';
};
$blackfireMiddleware = static function () use ($handler) {
    $probe = null;
    // Only create a Blackfire probe if the Blackfire header is present
    if (isset($_SERVER['HTTP_X_BLACKFIRE_QUERY'])) {
        $probe = new \BlackfireProbe($_SERVER['HTTP_X_BLACKFIRE_QUERY']);
        $probe->enable();
    }
    try {
        $handler();
    } catch (\Throwable $e) {
        throw $e;
    } finally {
        if (probe) {
            $probe->close();
        }
    }
};
// See https://frankenphp.dev/docs/worker/ for more information
$maxRequests = (int)($_SERVER['MAX_REQUESTS'] ?? 0);
for ($nbRequests = 0; !$maxRequests || $nbRequests < $maxRequests; ++$nbRequests) {
    $keepRunning = \frankenphp_handle_request($blackfireMiddleware);
    gc_collect_cycles();
    if (!$keepRunning) break;
}

Learn more about controlling Deterministic Profiling using the PHP SDK.

Read the original on docs.blackfire.io ↗