firephp/firephp-core
Core library for FirePHP: send server-side debugging messages from PHP to the browser via HTTP headers. Inspect variables, logs, warnings, traces and exceptions in real time with compatible browser extensions, without breaking page output.
Installation
composer require firephp/firephp-core
Add the service provider to config/app.php under providers:
FirePHP\FirePHP::class,
Basic Usage
Inject the FirePHP facade in your controller or service:
use FirePHP\FirePHP;
public function index(FirePHP $firephp)
{
$firephp->log('Hello, FirePHP!');
return view('welcome');
}
First Use Case Debug a variable in a route or controller:
$firephp->group('User Data')
->info($user)
->trace('User retrieval', ['source' => 'database']);
log(), info(), warn(), error(), group(), and trace().Debugging API Responses Log structured data before returning JSON:
$firephp->group('API Response')
->info($userData)
->trace('Query executed', ['sql' => $query]);
return response()->json($userData);
Middleware Integration Attach FirePHP to middleware for request/response logging:
public function handle($request, Closure $next)
{
$firephp = app(FirePHP::class);
$firephp->info('Request received', $request->all());
$response = $next($request);
$firephp->info('Response sent', $response->getData());
return $response;
}
Service Layer Logging Decorate services with logging:
public function fetchUser($id)
{
$firephp->trace('Fetching user', ['id' => $id]);
$user = User::find($id);
$firephp->info('User found', $user);
return $user;
}
Exception Handling
Log exceptions in App\Exceptions\Handler:
public function report(Throwable $exception)
{
$firephp = app(FirePHP::class);
$firephp->error('Uncaught exception', [
'message' => $exception->getMessage(),
'trace' => $exception->getTraceAsString(),
]);
}
barryvdh/laravel-debugbar for richer debugging:
$firephp->info('Debug data', $data);
Debugbar::info('Additional data', $data);
if (app()->environment('local')) {
$firephp->log('Development-only message');
}
$firephp->info('User', [
'id' => $user->id,
'name' => $user->name,
'email' => $user->email,
]);
Browser Extension Required
dd() or dump() for critical checks if the extension isn’t available.Performance Overhead
->trace() for verbose details.Group Nesting Limits
CSRF/Session Conflicts
if (!app()->environment('local')) {
$firephp->disable();
}
Legacy Package
barryvdh/laravel-debugbar or spatie/laravel-log-viewer for modern debugging.Log Not Appearing?
X-FirePHP-Version (FirePHP adds this header).Malformed Output
Clear Logs
$firephp->clear() to reset logs between requests (useful in tests or loops).Custom Log Levels Extend the facade to add domain-specific methods:
$firephp->audit('User action', ['action' => 'update', 'user_id' => 1]);
Implementation: Override the FirePHP facade or create a decorator.
Log to File + FirePHP Forward FirePHP logs to Laravel’s log channel:
$firephp->setHandler(function ($log) {
Log::channel('single')->info($log['message'], $log['data']);
});
Remote Debugging Use FirePHP to log data for remote servers where direct access is limited:
// Logs will appear in the browser of any user accessing the page.
$firephp->warn('Server misconfiguration', ['file' => $file, 'line' => $line]);
How can I help you explore Laravel packages today?