spatie/ray
Send debug output from any PHP app to Ray, Spatie’s desktop debugger. Inspect dumps, arrays, HTML, queries, and more with a consistent API across Laravel and vanilla PHP. Measure performance, pause execution, and keep fast feedback without cluttering logs.
spatie/ray aligns perfectly with Laravel’s debugging ecosystem (e.g., Laravel Debugbar, Tinker). It replaces dd(), dump(), and log() with a real-time, interactive desktop UI, reducing context-switching between terminal/IDE and browser.Log::channel(), Sentry). Supports structured data (queries, exceptions, variables) with rich formatting (Markdown, HTML, tables).ray()->stop('query')), enabling micro-optimizations without external tools like Blackfire.config/ray.php (supports queues, middleware, service providers).ray()->job().DB::listen or QueryObserver).try-catch debugging with stack traces in Ray’s UI, including variable states at each step.| Risk Area | Mitigation Strategy |
|---|---|
| Performance Overhead | Minimal in production (disabled via config). Development overhead is negligible (~5–10% for heavy debugging). |
| Data Leakage | Configurable to exclude sensitive data (e.g., passwords, tokens) via blacklists. |
| Compatibility | Actively maintained for PHP 8.1–8.5 and Laravel 10–13. Backward-compatible with PHP 7.4+. |
| Adoption Friction | Low: Replaces familiar dd()/dump() syntax. Zero-config for basic usage. |
| Network Dependency | Requires Ray desktop app (free tier available). Offline debugging via CLI logs. |
| State Management | Thread-safe for Swoole/React (PHP 8.1+ fibers). No shared state in multi-process setups. |
dd()/log()) or complementarily (e.g., for complex queries)?ray.php.afterSendCallbacks.ray()->ignore() for critical paths.Ray::log('Event fired')).RayMiddleware to log requests/responses globally.ray()->seeInLastRequest()).Ray::capture() in controllers/services.ray()->table($users).DB::listen or QueryObserver.ray()->query($sql, $bindings) for ad-hoc debugging.ray()->job($job, 'Processing order').ray()->exception($e) in HandleFailures.| Phase | Action | Rollout Strategy |
|---|---|---|
| Pilot | Enable Ray in 1–2 critical services (e.g., payments, auth). | Feature flag (config/ray.php['enabled']). |
| Developer Onboarding | Replace dd()/dump() with ray() in new PRs. Add Ray to CI for failed tests. |
Pair programming + dev portal docs. |
| Global Adoption | Enable Ray site-wide (excluding high-traffic APIs). | Gradual config push + monitoring. |
| Advanced Use | Custom payloads (e.g., ray()->api($request, $response)). |
Internal workshops. |
1.x branch.VarDumper, HttpFoundation (no conflicts).Ray::job()).composer require spatie/ray --dev
php artisan vendor:publish --provider="Spatie\Ray\RayServiceProvider"
config/ray.php:
'enabled' => env('RAY_ENABLED', false),
'ignore_exceptions' => [\SensitiveDataException::class],
use Spatie\Ray\Ray;
Ray::info('User logged in', ['user_id' => 123]);
Ray::dump($user); // Replaces dd()
Ray::query($query->toSql(), $query->getBindings());
Ray::log('Order created', ['order' => $order]).RayServiceProvider for domain-specific data.composer require spatie/ray --dev with update scripts.# .github/workflows/test.yml
- name: Test Ray
run: php artisan ray:test
config/ray.php via Laravel Envoy or Terraform.password, api_key).self:: → static::). Use rector for auto-fixes:
composer require rector/rector --dev
vendor/bin/rector process src --dry-run
RAY_ENABLED env var, firewall (port 8080), or queue:work processes.ray()->ignore() or increase ray.max_payload_size.RAY
How can I help you explore Laravel packages today?