PHPackages                             upscale/swoole-blackfire - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. upscale/swoole-blackfire

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

upscale/swoole-blackfire
========================

Blackfire profiler integration for Swoole web-server

4.3.0(1y ago)22114.0k—2.3%5[1 issues](https://github.com/upscalesoftware/swoole-blackfire/issues)8Apache-2.0PHPPHP &gt;=8.0CI failing

Since Jul 9Pushed 1y ago2 watchersCompare

[ Source](https://github.com/upscalesoftware/swoole-blackfire)[ Packagist](https://packagist.org/packages/upscale/swoole-blackfire)[ Docs](https://github.com/upscalesoftware/swoole-blackfire)[ RSS](/packages/upscale-swoole-blackfire/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (16)Used By (8)

Blackfire Profiler for Swoole [![Build Status](https://github.com/upscalesoftware/swoole-blackfire/workflows/Tests/badge.svg?branch=master)](https://github.com/upscalesoftware/swoole-blackfire/actions?query=workflow%3ATests+branch%3Amaster)
================================================================================================================================================================================================================================================

[](#blackfire-profiler-for-swoole-)

This library enables profiling of PHP applications running on [Swoole](https://github.com/swoole/swoole-src) / [Open Swoole](https://github.com/openswoole/swoole-src) web-server via [Blackfire](https://blackfire.io/).

**Features:**

- Transparent request profiling
- Selective sub-system profiling
- Custom start/stop profiling calls
- [Blackfire Companion](https://blackfire.io/docs/integrations/) integration

Installation
------------

[](#installation)

The library is to be installed via [Composer](https://getcomposer.org/) as a dev dependency:

```
composer require upscale/swoole-blackfire --dev
```

Usage
-----

[](#usage)

### Request Profiling

[](#request-profiling)

The easiest way to start profiling is to activate the profiler for all requests from start to finish. This approach is by design completely transparent to an application running on the server. No changes are needed beyond adding a few lines of code to the server entry point.

Install the profiling instrumentation for all requests:

```
$server->on('request', function ($request, $response) {
    $response->header('Content-Type', 'text/plain');
    $response->end(
        'CRC32: ' . hash_file('crc32b', __FILE__) . "\n" .
        'MD5:   ' . md5_file(__FILE__) . "\n" .
        'SHA1:  ' . sha1_file(__FILE__) . "\n"
    );
});

$profiler = new \Upscale\Swoole\Blackfire\Profiler();
$profiler->instrument($server);
```

### Selective Profiling

[](#selective-profiling)

It is possible to limit the profiling scope by wrapping the interested code in a profiler call.

Wrap the code intended to be profiled in the profiler call:

```
$profiler = new \Upscale\Swoole\Blackfire\Profiler();

$server->on('request', function ($request, $response) use ($profiler) {
    $response->header('Content-Type', 'text/plain');

    $profiler->inspect($request, $response, function ($request, $response) {
        $response->write('CRC32: ' . hash_file('crc32b', __FILE__) . "\n");
    });

    $response->write('MD5:   ' . md5_file(__FILE__) . "\n");
    $response->write('SHA1:  ' . sha1_file(__FILE__) . "\n");
});
```

Currently, only one profiler inspection call is permitted per request.

### Manual Profiling

[](#manual-profiling)

Depending on the application design and complexity, it may be difficult to precisely wrap desired code in the profiler call. Profiler start/stop calls can be manually placed at different call stack levels to further narrow down the inspection scope. Developer is responsible for the symmetry of the start/stop calls taking into account the response population workflow. The profiling must be stopped before sending the response body to be able to send the results in the response headers.

Surround the code intended to be profiled with the profiler start/stop calls:

```
$profiler = new \Upscale\Swoole\Blackfire\Profiler();

$server->on('request', function ($request, $response) use ($profiler) {
    $response->header('Content-Type', 'text/plain');

    $output = 'CRC32: ' . hash_file('crc32b', __FILE__) . "\n";

    $profiler->start($request);
    $output .= 'MD5:   ' . md5_file(__FILE__) . "\n";
    $profiler->stop($request, $response);

    $output .= 'SHA1:  ' . sha1_file(__FILE__) . "\n";

    $response->end($output);
});
```

Currently, only one pair of the profiler start/stop calls is permitted per request.

Limitations
-----------

[](#limitations)

The profiling implicitly stops before sending the response body and the results are added to the response headers. Currently, only one profiling session initiated by `inspect()` or `start/stop()` calls is supported per request.

Contributing
------------

[](#contributing)

Pull Requests with fixes and improvements are welcome!

License
-------

[](#license)

Copyright © Upscale Software. All rights reserved.

Licensed under the [Apache License, Version 2.0](https://github.com/upscalesoftware/swoole-blackfire/blob/master/LICENSE.txt).

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance42

Moderate activity, may be stable

Popularity42

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 98% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~172 days

Recently: every ~383 days

Total

15

Last Release

455d ago

Major Versions

1.0.1 → 2.0.02019-03-07

2.2.1 → 3.0.02019-05-23

3.1.0 → 4.0.02022-11-26

PHP version history (3 changes)2.2.1PHP &gt;=5.5

3.1.0PHP &gt;=7.1

4.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ff1791f1bd72221702e39e356c25b108de26dea1f5b56416f7957e8fa43ea92?d=identicon)[upscalesoftware](/maintainers/upscalesoftware)

---

Top Contributors

[![sshymko](https://avatars.githubusercontent.com/u/1231423?v=4)](https://github.com/sshymko "sshymko (49 commits)")[![Rastusik](https://avatars.githubusercontent.com/u/1735097?v=4)](https://github.com/Rastusik "Rastusik (1 commits)")

---

Tags

profilerprofilingswooleintegrationblackfirecompanionBlackfire.io

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/upscale-swoole-blackfire/health.svg)

```
[![Health](https://phpackages.com/badges/upscale-swoole-blackfire/health.svg)](https://phpackages.com/packages/upscale-swoole-blackfire)
```

###  Alternatives

[barryvdh/laravel-debugbar

PHP Debugbar integration for Laravel

19.2k124.3M624](/packages/barryvdh-laravel-debugbar)[php-debugbar/php-debugbar

Debug bar in the browser for php application

4.4k21.3M40](/packages/php-debugbar-php-debugbar)[fruitcake/laravel-debugbar

PHP Debugbar integration for Laravel

19.1k662.9k29](/packages/fruitcake-laravel-debugbar)[tracy/tracy

😎 Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.

1.8k24.4M1.3k](/packages/tracy-tracy)[fruitcake/laravel-telescope-toolbar

Toolbar for Laravel Telescope based on Symfony Web Profiler

8041.6M3](/packages/fruitcake-laravel-telescope-toolbar)[laracraft-tech/laravel-xhprof

Easy XHProf setup to profile your laravel application!

235321.4k](/packages/laracraft-tech-laravel-xhprof)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
