PHPackages                             rayzenai/ray - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. rayzenai/ray

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

rayzenai/ray
============

A lightweight Ray-like debugging tool for Laravel applications

v2.1.0(1mo ago)12.0kMITBladePHP ^8.3

Since Jan 4Pushed 1mo agoCompare

[ Source](https://github.com/rayzenai/ray)[ Packagist](https://packagist.org/packages/rayzenai/ray)[ RSS](/packages/rayzenai-ray/feed)WikiDiscussions main Synced today

READMEChangelog (4)Dependencies (6)Versions (6)Used By (0)

Ray Debug for Laravel
=====================

[](#ray-debug-for-laravel)

A lightweight Ray-like debugging tool for Laravel applications with a web-based debug viewer.

Features
--------

[](#features)

- `ray()` helper function for quick debugging
- Automatic slow query logging (configurable threshold)
- Request profiling middleware (N+1 detection, memory usage)
- **Mail driver** that records sent emails to the viewer (great for tests)
- Web-based debug viewer at `/debug/ray`
- Color-coded entries (red, orange, yellow, green, blue)
- Configurable access control via email whitelist

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11 or 12

Installation
------------

[](#installation)

```
composer require rayzenai/ray
```

Configuration
-------------

[](#configuration)

Publish the config file:

```
php artisan vendor:publish --tag=ray-config
```

This creates `config/ray.php`:

```
return [
    // Define allowed users by email
    // Use ['*'] to allow all authenticated users
    'allowed_emails' => [
        // '*',
        // 'admin@example.com',
    ],

    // User model configuration (for apps with custom user tables)
    'user_model' => \App\Models\User::class,
    'user_email_field' => 'email',

    // Queries slower than this (ms) are auto-logged
    'slow_query_threshold' => 100,

    // Max debug entries to keep
    'max_entries' => 100,

    // Storage location
    'storage_path' => storage_path('logs/ray-debug.json'),
];
```

Usage
-----

[](#usage)

### Basic Debugging

[](#basic-debugging)

```
// Simple debug
ray($variable);

// With label — when two arguments are passed, the first becomes the label
ray('user data', $user);

// With colors
ray($data)->red();
ray($data)->green();
ray($data)->blue();
ray($data)->yellow();
ray($data)->orange();
ray($data)->purple();

// Chained
ray($data)->label('My Label')->green();

// Pause — highlights the entry as paused (orange) so it stands out in the viewer
ray($data)->pause();

// Inline — log and return the original value so you can wrap an expression
$user = ray($repository->find($id))->label('user')->value();
```

### Static Methods

[](#static-methods)

```
// Semantic logging
Ray::error($data);    // Red
Ray::warning($data);  // Yellow
Ray::success($data);  // Green
Ray::info($data);     // Blue

// Performance
Ray::measure('label');        // Start timer
// ... code ...
Ray::measure('label');        // Stop & log elapsed time

Ray::memory();                // Log memory usage

// Debugging
Ray::trace();                 // Log stack trace
Ray::caller();                // Log caller info

// Query logging
Ray::showQueries();           // Start logging all queries
Ray::showSlowQueries(50);     // Log queries > 50ms
Ray::stopQueries();           // Stop logging
Ray::querySummary();          // Get query stats
```

### Counter

[](#counter)

```
// Count iterations
foreach ($items as $item) {
    Ray::count('loop');       // Increments each call
}

Ray::resetCount('loop');      // Reset counter
```

### Die &amp; Dump

[](#die--dump)

```
ray($data)->die();            // Log and exit

// Or use helper
rayDie($data, 'label');
```

Request Profiler Middleware
---------------------------

[](#request-profiler-middleware)

Add the middleware to log slow requests and detect N+1 queries:

```
// app/Http/Kernel.php
protected $middlewareGroups = [
    'web' => [
        // ... other middleware
        \RayzenAI\Ray\Middleware\RayRequestProfiler::class,
    ],
];
```

The profiler automatically logs:

- Requests taking &gt; 100ms
- Requests using &gt; 25MB memory
- N+1 query detection (same query 3+ times)

Mail Driver
-----------

[](#mail-driver)

Ray ships a Symfony mailer transport that records every outgoing email to the debug viewer instead of sending it. Perfect for inspecting mails generated by tests or local seeders.

Add it to `config/mail.php`:

```
'mailers' => [
    // ...
    'ray' => [
        'transport' => 'ray',
    ],
],
```

Then point your environment at it (typically in `.env.testing` or `phpunit.xml`):

```
MAIL_MAILER=ray

```

Recorded mails show up under the **Mail** tab at `/debug/ray` with full headers, an HTML preview (rendered in a sandboxed iframe), the text alternative, and an attachment summary. The transport itself works in any environment — only the viewer is gated to `local`.

Debug Viewer
------------

[](#debug-viewer)

Once installed, the package automatically registers the dashboard route. Open it in your browser at:

```
http://your-app.test/debug/ray

```

The route is registered with the `web` middleware group under the `debug/ray` prefix, and is only accessible in the `local` environment. Access is further restricted by the `allowed_emails` config (see [Security](#security)).

Features:

- Tabs: Debug, Mail, Requests, Queries
- Color filters
- Search
- Auto-refresh toggle
- Expand/collapse entries
- Copy to clipboard
- Delete individual entries or clear all

Security
--------

[](#security)

The package only works in `local` environment. Access is controlled by:

1. **Empty config** - Shows error message prompting configuration
2. **Wildcard `['*']`** - Allows all authenticated users
3. **Email list** - Only specified emails can access

License
-------

[](#license)

MIT

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance90

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~32 days

Total

5

Last Release

51d ago

Major Versions

1.0.1 → 2.0.02026-05-05

PHP version history (2 changes)v1.0.0PHP ^8.2

2.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/351e3224dcfda5f2fc1a86fb6424f60a9a060a39c938c6338a244d01912e077d?d=identicon)[kiran1991](/maintainers/kiran1991)

---

Top Contributors

[![timsinakiran](https://avatars.githubusercontent.com/u/50225225?v=4)](https://github.com/timsinakiran "timsinakiran (14 commits)")

### Embed Badge

![Health badge](/badges/rayzenai-ray/health.svg)

```
[![Health](https://phpackages.com/badges/rayzenai-ray/health.svg)](https://phpackages.com/packages/rayzenai-ray)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[livewire/livewire

A front-end framework for Laravel.

23.6k89.0M2.7k](/packages/livewire-livewire)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.6k29.9M145](/packages/laravel-cashier)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M131](/packages/laravel-pulse)[api-platform/laravel

API Platform support for Laravel

58170.8k14](/packages/api-platform-laravel)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
