FrankenPHP beta
PHP

FrankenPHP support is currently in beta. At this stage, we only support deterministic profiling. Additional capabilities are in development.

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

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

Alternatively, you can use the FrankenPHP base Docker image:

1
2
3
4
5
6
7
8
9
10
11
Loading...

If you're using Laravel Octane with FrankenPHP, our integration already supports Deterministic Profiling out of the box for both the classic and worker modes.

The Blackfire PHP probe already supports classic mode without requiring additional configuration.

FrankenPHP worker mode requires updating the worker script in order to control the instrumentation:

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
<?php

ignore_user_abort(true);

$handler = static function () {
    echo 'Hello Blackfire!';
};

$blackfireMiddleware = static function () use ($handler) {
    $probe = \BlackfireProbe::getMainInstance();
    $probe->enable();
    try {
        $handler();
    } catch (\Throwable $e) {
        throw $e;
    } finally {
        $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.