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 debugger. Use a consistent “ray()” API to inspect variables, arrays, HTML, queries, and more, measure performance, and pause execution. Works alongside PHP, JS, and other integrations.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Debugging Paradigm: The package aligns perfectly with Laravel’s debugging ecosystem, offering a real-time, desktop-based alternative to dd(), dump(), and Laravel’s built-in logging. It integrates seamlessly with Laravel’s service container, Blade templates, and event system, making it a natural fit for teams already using Spatie’s tools (e.g., laravel-activitylog, laravel-permission).
  • Modularity: The package is lightweight (~100KB) and opt-in, allowing teams to enable/disable debugging per environment (e.g., local only) without affecting production performance.
  • Extensibility: Supports custom watchers (e.g., for Eloquent queries, HTTP requests, or queues) and integrates with Ray’s MCP server for AI-assisted debugging, future-proofing for advanced use cases.

Integration Feasibility

  • Laravel Compatibility: Officially supports Laravel 11–13 (as of v1.43.6) with backward compatibility for older versions. The package leverages Laravel’s service provider and facade patterns, reducing friction for adoption.
  • PHP Version Support: Works with PHP 8.1–8.5, with explicit fixes for deprecations (e.g., PHP 8.4/8.5 compatibility in v1.36.1/v1.41.0). No breaking changes expected for supported versions.
  • Dependency Conflicts: Minimal risk—primary dependency (spatie/ray) is isolated and version-locked. Composer’s autoloader handles conflicts gracefully.

Technical Risk

  • Performance Overhead:
    • Low in production: Debug output is environment-agnostic (disabled via .env or config). No runtime cost when inactive.
    • Local development: Minimal overhead (~1–5ms per ray() call), but batch processing (e.g., queue workers) may require monitoring for latency spikes.
  • Data Privacy:
    • Sensitive data exposure: Risk if ray() is used with request payloads, tokens, or PII. Mitigation: Use context filters or environment checks (if (app()->environment('local'))).
    • Storage: Ray messages are local-only by default; no cloud dependency unless using MCP server.
  • Breakage Potential:
    • Blade/Query Watchers: Custom watchers (e.g., for Eloquent) may require manual updates if Laravel’s query builder or ORM changes (e.g., v10 → v11 migrations).
    • Artisan Commands: The ray:clean command (v1.34.0+) uses Rector, which could conflict with existing codebase transformations.

Key Questions

  1. Debugging Workflow:
    • How will the team adopt Ray vs. existing tools (e.g., Laravel Telescope, Xdebug)? Will this replace dd()/dump() entirely, or supplement them?
  2. Environment Strategy:
    • Should Ray be disabled in staging (e.g., via RAY_ENABLED=false) to avoid accidental leaks?
  3. Data Sensitivity:
    • Are there PII or security-sensitive areas where ray() cannot be used? If so, how will these be guarded?
  4. Performance Baseline:
    • For high-throughput systems (e.g., APIs), what’s the acceptable latency for debug output? Will batching (e.g., queue workers) be needed?
  5. Team Onboarding:
    • How will developers be trained to use Ray effectively (e.g., context grouping, performance measurement) vs. falling back to dd()?
  6. Long-Term Maintenance:
    • Who will update the package (e.g., Laravel 14 support) and handle dependency upgrades (e.g., spatie/ray v2.0)?

Integration Approach

Stack Fit

  • Laravel Ecosystem:
    • Native Integration: Works out-of-the-box with Laravel’s facades, Blade directives (@ray), and service container. No need for monolithic refactoring.
    • Toolchain Synergy: Complements Spatie’s other packages (e.g., laravel-activitylog) and tools like Laravel Forge/Vapor for deployment-aware debugging.
  • Tech Stack Compatibility:
    • PHP 8.1+: No polyfills needed; leverages modern PHP features (e.g., named arguments, attributes).
    • Frontend: Ray’s cross-language support (JavaScript/TypeScript) enables full-stack debugging if the team uses Laravel Mix/Vite.
    • Databases: Supports raw SQL, Eloquent queries, and query watchers for PostgreSQL/MySQL/SQLite.

Migration Path

  1. Pilot Phase:
    • Install in a non-production environment (e.g., local or staging):
      composer require spatie/laravel-ray
      php artisan ray:install
      
    • Configure .env:
      RAY_ENABLED=true
      RAY_PORT=8000
      
    • Test with critical paths (e.g., checkout flow, API endpoints) to validate performance and data safety.
  2. Incremental Adoption:
    • Replace dd()/dump(): Use @ray in Blade or ray() in PHP for targeted debugging.
    • Add Watchers: Enable built-in watchers (e.g., queries, emails) via config:
      'watchers' => [
          \Spatie\Ray\Watchers\QueriesWatcher::class,
          \Spatie\Ray\Watchers\ExceptionsWatcher::class,
      ],
      
    • Custom Watchers: Extend for domain-specific needs (e.g., UserService logs).
  3. Production Readiness:
    • Disable in production: Set RAY_ENABLED=false and validate no debug calls leak.
    • Monitor: Use Laravel Horizon or Sentry to track ray() usage in non-local environments.

Compatibility

  • Laravel Versions:
    • Drop-in for 11–13: No changes needed for supported versions.
    • Legacy Support: Use ^1.35.0 for Laravel 10 (deprecated in v1.36.0+).
  • Dependency Conflicts:
    • Low Risk: spatie/ray is a soft dependency; conflicts are rare. Use composer why-not to pre-check.
    • Mail MIME Parser: Updated to v3 in v1.36.3; ensure no conflicts with zbateson/mail-mime-parser.
  • IDE Support:
    • PHPStorm/VSCode: Ray’s IntelliSense works with Laravel’s IDE helpers. Add to composer.json:
      "extra": {
          "laravel": {
              "providers": ["Spatie\\Ray\\RayServiceProvider"]
          }
      }
      

Sequencing

  1. Phase 1: Core Debugging (2–4 weeks)
    • Replace dd() with ray() in critical modules.
    • Validate performance impact (e.g., API response times).
  2. Phase 2: Advanced Features (1–2 weeks)
    • Enable watchers (queries, exceptions, emails).
    • Implement custom watchers for business logic.
  3. Phase 3: Full-Stack Debugging (Optional)
    • Integrate Ray’s JavaScript client for frontend debugging.
    • Set up MCP server for AI-assisted debugging.
  4. Phase 4: Optimization
    • Audit for sensitive data leaks in ray() calls.
    • Disable in non-local environments via CI/CD gates.

Operational Impact

Maintenance

  • Package Updates:
    • Minimal Effort: Follow Spatie’s semver (e.g., ^1.43 for Laravel 13). Updates are backward-compatible unless major Laravel versions change.
    • Dependency Management: Use composer why spatie/laravel-ray to track updates. Test in a staging branch before merging.
  • Debugging Overhead:
    • Proactive Cleanup: Use php artisan ray:clean to remove debug calls in PRs (v1.34.0+).
    • Context Management: Group related ray() calls with context labels (e.g., ray('User', ['id' => $user->id])).

Support

  • Troubleshooting:
    • Common Issues:
      • Ray not connecting: Check RAY_PORT and firewall rules.
      • Missing data: Ensure RAY_ENABLED=true and no environment filters block output.
      • Performance lag: Reduce ray() calls in loops; use batch processing.
    • Logs: Ray’s local storage (storage/ray) can be inspected if the app crashes.
  • Team Training:
    • **Documentation
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport