Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Ray Laravel Package

spatie/laravel-ray

Send Laravel debug output to Ray, Spatie’s desktop debugging app. Use a consistent API to inspect variables, arrays, HTML, queries and more, measure performance, and pause execution. Works across Laravel/PHP with Ray’s rich UI.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Debugging-Centric: spatie/laravel-ray is a debugging-first package, aligning perfectly with Laravel applications where real-time debugging (e.g., queries, variables, exceptions) is critical. It integrates seamlessly with Laravel’s event system, service container, and Blade templates, making it a low-friction addition to existing debugging workflows.
  • Multi-Layer Visibility: Supports debugging at the application layer (e.g., HTTP requests, exceptions), database layer (queries, Eloquent models), Blade layer (view variables), and email layer (mailables). This holistic visibility reduces context-switching during debugging.
  • Performance Profiling: The measure directive and query watchers enable performance bottlenecks identification, which is valuable for optimizing Laravel applications under load.
  • AI/ML Context: The package’s compatibility with MCP (Machine Learning Context Protocol) suggests potential for debugging AI-driven Laravel features (e.g., NLP pipelines, recommendation systems), though this is niche.

Integration Feasibility

  • Laravel-Specific: Designed exclusively for Laravel, with zero configuration required beyond installation (via spatie/ray dependency). Leverages Laravel’s service provider and facade patterns for minimal boilerplate.
  • Non-Intrusive: Debugging output is opt-in (e.g., ray() helper, Blade directives like @ray) and does not modify core application logic. Existing dd(), dump(), or Log usage can coexist.
  • Query/Event Hooks: Automatically captures Eloquent queries, exceptions, and HTTP requests without manual instrumentation, reducing developer effort.
  • Blade Integration: Blade directives (@ray, @xray) enable runtime variable inspection directly in views, which is particularly useful for debugging UI logic.

Technical Risk

  • Dependency on Ray Desktop App: Requires external desktop software (Ray) for visualization, which may introduce onboarding friction for developers unfamiliar with the tool. However, the free tier (20 messages/session) mitigates this.
  • Performance Overhead: Debugging output is network-bound (sends data to Ray). In high-throughput environments (e.g., APIs with 10K+ RPS), this could introduce latency if not throttled. The package includes configurable limits (e.g., RAY_MAX_MESSAGES) to mitigate this.
  • PHP Version Compatibility: Actively maintained for PHP 8.1+, with explicit fixes for PHP 8.5 deprecations (e.g., strtolower null handling). Laravel 11–13 support is confirmed, but older versions (pre-Laravel 9) may require backporting.
  • Security: Debug output may expose sensitive data (e.g., request payloads, query results). The package includes context filtering (e.g., Ray::ignore()) and environment-based toggling (config('ray.enabled')), but teams must enforce least-privilege usage in production.
  • Ray License Cost: While the MIT-licensed package is free, Ray’s full features require a paid license (though the free tier is generous for development).

Key Questions

  1. Debugging Workflow Alignment:

    • Does the team already use Ray or similar tools (e.g., Laravel Telescope, DebugBar)? If not, what’s the adoption cost for onboarding?
    • How will Ray’s output be integrated into existing debugging pipelines (e.g., Slack alerts, monitoring dashboards)?
  2. Performance Impact:

    • What’s the baseline throughput of the application? Will RAY_MAX_MESSAGES need tuning to avoid network bottlenecks?
    • Are there critical paths (e.g., payment processing) where debugging output must be disabled entirely?
  3. Data Sensitivity:

    • How will PII or sensitive data in debug output be handled? Are there automated redaction rules needed?
    • Should Ray be disabled in production entirely, or used selectively (e.g., via feature flags)?
  4. Tooling Ecosystem:

    • Will Ray replace existing tools (e.g., Telescope, Xdebug)? If so, what’s the migration path for saved queries/debug sessions?
    • Are there plans to extend Ray for custom debugging (e.g., business logic validation)?
  5. Long-Term Maintenance:

    • How will the team handle Ray license renewals if scaling beyond the free tier?
    • Is there a fallback plan if Ray’s desktop app becomes deprecated or incompatible?

Integration Approach

Stack Fit

  • Laravel-Centric: Optimized for Laravel’s service container, events, and Blade engine. No conflicts with core Laravel features.
  • PHP Ecosystem: Compatible with Eloquent, Queues, Mail, and HTTP clients (via watchers). Works alongside:
    • Debugging: Xdebug, Telescope, Laravel Debugbar.
    • Monitoring: Sentry, Laravel Horizon.
    • Logging: Monolog, Papertrail.
  • Multi-Language: Ray’s cross-language support (JavaScript, Python) is irrelevant for PHP/Laravel but may appeal to full-stack teams.

Migration Path

  1. Pilot Phase:

    • Install in a non-production environment (e.g., staging) with RAY_ENABLED=false by default.
    • Enable for specific developers or critical paths (e.g., /admin routes) via config('ray.enabled').
    • Use ray() sparingly to test output volume and performance impact.
  2. Gradual Rollout:

    • Replace select dd()/dump() calls with ray() for structured debugging.
    • Leverage Blade directives (@ray, @xray) in templates to inspect view data.
    • Configure query watchers to log slow queries (replace Telescope if used).
  3. Production Readiness:

    • Disable Ray in production by default, but enable via environment variables (e.g., RAY_ENABLED=true in .env) for emergencies.
    • Set RAY_MAX_MESSAGES=10 to limit output volume.
    • Use Ray::ignore() to exclude sensitive data (e.g., passwords, tokens).

Compatibility

  • Laravel Versions: Officially supports Laravel 11–13. Laravel 10 requires v1.35.x; pre-9 needs backporting.
  • PHP Versions: PHP 8.1+ (PHP 8.5 fixes included). PHP 7.x unsupported.
  • Dependencies:
    • Requires spatie/ray (≥v1.45.0), which may introduce minor breaking changes (monitor Spatie’s changelog).
    • Compatible with Laravel’s default packages (e.g., Eloquent, Mail, Queues).
  • IDE/Tooling: No IDE-specific requirements, but VS Code’s PHP Intelephense may need updates for Ray’s helpers.

Sequencing

  1. Installation:

    composer require spatie/laravel-ray
    php artisan vendor:publish --provider="Spatie\Ray\RayServiceProvider"
    
    • Configure .env and config/ray.php.
  2. Core Setup:

    • Add Ray’s facade to config/app.php:
      'aliases' => [
          'Ray' => Spatie\Ray\Ray::class,
      ],
      
    • Publish assets (if using Ray’s Blade directives).
  3. Debugging Activation:

    • Enable for specific routes or developers:
      if (app()->environment('local') || auth()->user()->isDebugger()) {
          Ray::enable();
      }
      
    • Replace dd($var) with ray($var) for structured output.
  4. Advanced Features:

    • Configure query watchers to log slow queries:
      Ray::queryWatcher()->enable();
      
    • Use @ray in Blade to inspect variables:
      @ray($user)
      
    • Set up performance measurement:
      Ray::measure('user_creation', function () {
          User::create([...]);
      });
      
  5. Monitoring:

    • Exclude sensitive data:
      Ray::ignore('password', 'api_token');
      
    • Limit message volume:
      RAY_MAX_MESSAGES=20
      

Operational Impact

Maintenance

  • Low Overhead:
    • No database migrations or schema changes required.
    • Zero runtime configuration beyond initial setup.
    • Automatic updates: Composer handles spatie/ray updates; Laravel’s package auto-loader ensures compatibility.
  • Dependency Management:
    • Monitor spatie/ray for breaking changes (e.g., API shifts in Ray’s desktop app).
    • Pin versions in composer.json if using **
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai