blackfire/php-sdk
Blackfire PHP SDK provides a client for programmatic profiling with Blackfire, plus integrations like PHPUnit. Includes an optional proxy to inspect profiling traffic and a pure-PHP probe fallback for environments where the Blackfire extension can’t be installed.
kernel.handled, illuminate.query) pairs well with Blackfire’s scenario-based profiling (e.g., startScenario()/closeScenario()).BlackfiredHttpClient enables automatic HTTP request profiling, ideal for Laravel’s route-based architecture.handle() in jobs) remains feasible, though no native Laravel queue worker integration exists.Blackfire\Client in AppServiceProvider or a dedicated package).composer require blackfire/php-sdk:^3.0) with no breaking changes for new adopters. Existing v2.x users must update deprecated method calls (e.g., startScenario() instead of createBuild()).BlackfiredHttpClient (e.g., app/Http/Middleware/ProfileRequests.php).$this->app->singleton(Blackfire\Client::class, fn() => new Blackfire\Client('your_token'));
illuminate.query for database profiling).Blackfire\startScenario()/closeScenario().blackfire-io-proxy.php and PHP Probe provide options for environments where the Blackfire PHP extension cannot be installed (e.g., shared hosting).startScenario() instead of createBuild()). Use composer why-not blackfire/php-sdk:^3.0 to audit dependencies.illuminate.query events or manual SQL tagging)?blackfire-io-proxy.php?Blackfire::profileRoute())?BlackfiredHttpClient middleware for routes.kernel.handled, illuminate.query).Blackfire\Client as a singleton for dependency injection.handle()).createBuild()).composer require blackfire/php-sdk:^3.0.startScenario() instead of createBuild()).Blackfire\Client::getScenarioReport() for validation.BlackfiredHttpClient to profile HTTP requests:
// app/Http/Middleware/ProfileRequests.php
public function handle($request, Closure $next) {
Blackfire\startScenario('route: ' . $request->route()->getName());
return $next($request);
}
$this->app->singleton(Blackfire\Client::class, fn() => new Blackfire\Client(config('blackfire.token')));
// app/Listeners/ProfileQueries.php
public function handle($event) {
Blackfire\addContext('sql', $event->sql);
}
@blackfire annotations).- name: Profile with Blackfire
run: vendor/bin/phpunit --blackfire
blackfire-io-proxy.php for traffic inspection.@blackfire annotations.How can I help you explore Laravel packages today?