PHPackages                             barbushin/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. barbushin/swoole-blackfire

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

barbushin/swoole-blackfire
==========================

Blackfire profiler for PHP applications running on Swoole web-server

2.1.2(7y ago)05Apache-2.0PHPPHP &gt;=5.4

Since Jul 9Pushed 7y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (2)Versions (8)Used By (0)

Blackfire Profiler for Swoole
=============================

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

This library enables profiling of PHP applications running on [Swoole](https://www.swoole.co.uk/) 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 globally for all requests from start to finish. This approach is by design completely transparent to an application running on the server. No code changes are needed beyond editing a few lines of code in the server entry point.

Activate profiling of all requests using one of the following methods:

- Wrap the server middleware in the profiler decorator: ```
    $profiler = new \Upscale\Swoole\Blackfire\Profiler();

    $server->on('request', $profiler->wrap(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"
        );
    }));
    ```
- Or, install the profiler instrumentation retroactively: ```
    $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. With this approach, a developer must guarantee the symmetry of the calls and consider 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](http://www.apache.org/licenses/LICENSE-2.0).

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 92.3% 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 ~42 days

Recently: every ~3 days

Total

7

Last Release

2654d ago

Major Versions

1.0.1 → 2.0.02019-03-07

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/683352?v=4)[Sergey](/maintainers/barbushin)[@barbushin](https://github.com/barbushin)

---

Top Contributors

[![sshymko](https://avatars.githubusercontent.com/u/1231423?v=4)](https://github.com/sshymko "sshymko (24 commits)")[![barbushin](https://avatars.githubusercontent.com/u/683352?v=4)](https://github.com/barbushin "barbushin (2 commits)")

---

Tags

profilerprofilingswooleblackfire

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-debugbar

PHP Debugbar integration for Laravel

19.2k130.0M721](/packages/barryvdh-laravel-debugbar)[fruitcake/laravel-debugbar

PHP Debugbar integration for Laravel

19.2k1.7M55](/packages/fruitcake-laravel-debugbar)[upscale/swoole-blackfire

Blackfire profiler integration for Swoole web-server

22120.7k10](/packages/upscale-swoole-blackfire)[php-debugbar/php-debugbar

Debug bar in the browser for php application

4.4k26.7M61](/packages/php-debugbar-php-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.8k25.1M1.4k](/packages/tracy-tracy)[fruitcake/laravel-telescope-toolbar

Toolbar for Laravel Telescope based on Symfony Web Profiler

8061.7M5](/packages/fruitcake-laravel-telescope-toolbar)

PHPackages © 2026

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