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.
Profiling Integration: The blackfire/php-sdk v3.0.0 aligns seamlessly with Laravel’s architecture, offering low-overhead profiling for HTTP requests, queues, and CLI commands. The removal of deprecated v2.x functions simplifies integration, reducing technical debt for long-term maintenance.
BlackfiredHttpClient for HTTP profiling).handle() methods) remains necessary but is streamlined by v3.0.0’s cleaner API.illuminate.query, kernel.handled) for granular profiling.Laravel-Specific Strengths:
AppServiceProvider), but the SDK’s simplicity offsets this.Blackfire\startScenario().Limitations:
handle() in jobs).startScenario() replaces createBuild).Profiling Scope:
Integration Strategy:
Cost/Compliance:
Alternatives:
Laravel-Specific:
Blackfire::profileRoute())?BlackfiredHttpClient).Blackfire\Client as a singleton.kernel.handled).Blackfire\startScenario().@blackfire annotations or test listeners.New Projects:
composer require blackfire/php-sdk:^3.0.Blackfire\Client directly or wrap in a Laravel facade.public function handle($request, Closure $next) {
Blackfire\startScenario('route-profiling');
return $next($request);
}
Upgrading from v2.x:
createBuild → startScenario).Profile\Configuration).Legacy Systems:
Phase 1: CI/CD Integration
@blackfire annotations).- uses: actions/checkout@v4
- run: composer require blackfire/php-sdk:^3.0
- run: vendor/bin/phpunit --blackfire
Phase 2: Production Profiling
Phase 3: Advanced Use Cases
Phase 4: Optimization
Blackfire\Client::getScenarioReport() for troubleshooting.bin/blackfire-io-proxy.php) can inspect traffic for debugging.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Blackfire API downtime | Profiling data unavailable. | Retry logic in Blackfire\Client (configurable). |
| SDK misconfiguration | No profiles generated. | Validate Blackfire\Configuration setup. |
| PHP extension missing | Profiling fails. | Use PHP Probe fallback (legacy/XHProf). |
| High profiling volume | Cost overruns or performance hit. | Set sampling rates or profile selectively. |
| Laravel cache issues | Middleware/bindings fail. | Clear cache (php artisan cache:clear). |
startScenario, getScenarioReport).@blackfire in test suites.How can I help you explore Laravel packages today?