devportolio/laravel-dump-viewer

A beautiful, modern in-browser debugging tool for Laravel with persistent storage, real-time updates, and an intuitive interface. Inspired by Spatie Ray.

Maintainers

Package info

github.com/devportolio/laravel-dump-viewer

pkg:composer/devportolio/laravel-dump-viewer

Statistics

Installs: 43

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.1.0 2025-12-29 18:46 UTC

This package is auto-updated.

Last update: 2026-03-29 01:14:03 UTC


README

Laravel Version PHP Version License

A beautiful, modern, and powerful in-browser debugging tool for Laravel applications. Inspired by Spatie Ray, but designed as a web-based viewer with persistent storage, real-time updates, and an intuitive interface.

โœจ Features

๐ŸŽฏ Core Features

  • ๐ŸŒ Web-Based Viewer - View dumps in a beautiful, dedicated web interface
  • ๐Ÿ’พ Persistent Storage - Dumps survive page refreshes and stay available across requests
  • ๐Ÿ”„ Real-Time Updates - Auto-refresh to see new dumps as they arrive
  • ๐Ÿท๏ธ Smart Labeling - Organize dumps with custom labels and filter by them
  • ๐ŸŽจ Syntax Highlighting - SQL queries with beautiful formatting
  • ๐ŸŒ“ Dark/Light Modes - Automatically adapts to your preference
  • ๐Ÿ“ฑ Responsive Design - Works perfectly on all screen sizes

๐Ÿš€ Advanced Features

  • โšก Tinker Support - Works seamlessly in php artisan tinker
  • ๐Ÿ” Smart Detection - Automatically detects and formats SQL queries
  • ๐Ÿ“Š Collection Handling - Beautifully renders Laravel Collections and Models
  • ๐ŸŽฏ Multiple Dumps - Dump multiple values in a single call
  • ๐Ÿ”— Fluent API - Chain methods like ->label() and ->stop()
  • ๐ŸŽจ Unique Colors - Each label gets a unique, consistent color
  • ๐Ÿ“ˆ Performance Mode - Handles large datasets with smart truncation

๐Ÿ“ฆ Installation

Requirements

  • PHP 8.2 or higher
  • Laravel 10.x, 11.x, or 12.x

Install via Composer

composer require devportolio/laravel-dump-viewer --dev

Publish Configuration (Optional)

php artisan vendor:publish --tag=dump-viewer-config

Publish Assets (Optional)

php artisan vendor:publish --tag=dump-viewer-assets

๐ŸŽฏ Quick Start

Basic Usage

// Simple dump
dumpx($user);

// Dump with label
dumpx($user)->label('User Data');

// Dump multiple values
dumpx($user, $post, $comments);

// Multiple values with label
dumpx($a, $b, $c)->label('Debug Values');

// Label and stop
dumpx($data)->label('Final State')->stop();

View Your Dumps

After calling dumpx(), open your browser to:

http://your-app.test/dump-viewer

๐Ÿ“– Usage Guide

In Web Requests

Route::get('/test', function () {
    $user = User::first();
    
    // Dump the user
    dumpx($user)->label('First User');
    
    // Continue execution
    return view('test');
});

In Tinker

php artisan tinker

>>> $user = User::first()
>>> dumpx($user)->label('User from Tinker')
>>> dumpx(User::count())->label('Total Users')

Then open the viewer in your browser to see the dumps!

In Artisan Commands

class MyCommand extends Command
{
    public function handle()
    {
        $data = $this->fetchData();
        
        dumpx($data)->label('Command Data');
        
        $this->info('Data dumped to viewer!');
    }
}

SQL Query Debugging

$query = DB::table('users')
    ->where('active', true)
    ->toSql();

dumpx($query)->label('User Query');
// Automatically formats with syntax highlighting!

Eloquent Model Debugging

$user = User::with('posts', 'comments')->first();

dumpx($user)->label('User with Relations');
// Beautifully renders model attributes and relationships

Collection Debugging

$users = User::take(100)->get();

dumpx($users)->label('Users Collection');
// Smart rendering with expand/collapse

โš™๏ธ Configuration

After publishing the config file, you can customize:

// config/dump-viewer.php

return [
    // Enable/disable the dump viewer
    'enabled' => env('DUMPX_ENABLED', true),
    
    // Route to access the viewer
    'route' => env('DUMPX_ROUTE', 'dump-viewer'),
    
    // Maximum dumps to store
    'storage_limit' => env('DUMPX_STORAGE_LIMIT', 500),
    
    // Storage driver (file, redis, database, etc.)
    'storage_driver' => env('DUMPX_STORAGE_DRIVER', 'file'),
    
    // Middleware for the viewer route
    'middleware' => ['web'],
];

Environment Variables

Add to your .env file:

# Enable/disable dump viewer
DUMPX_ENABLED=true

# Custom route
DUMPX_ROUTE=dump-viewer

# Storage settings
DUMPX_STORAGE_DRIVER=file
DUMPX_STORAGE_LIMIT=500

๐ŸŽจ Interface Features

Header Controls

  • ๐Ÿ” Filter by Label - Click labels to filter dumps
  • ๐Ÿ“Š Sort Options - Sort by time, label, or file
  • โคข Expand/Collapse All - Toggle all dumps at once
  • โšก Auto-Refresh Toggle - Enable/disable real-time updates
  • ๐ŸŒ“ Theme Toggle - Switch between dark and light modes
  • ๐Ÿ—‘๏ธ Clear All - Remove all dumps with one click

Dump Item Features

  • ๐Ÿ“‚ Collapsible Content - Click to expand/collapse
  • ๐Ÿท๏ธ Color-Coded Labels - Each label has a unique color
  • ๐Ÿ“ File Location - Shows file path and line number
  • โฐ Timestamp - When the dump was created
  • ๐Ÿ“‹ Type Badge - Shows data type (Array, Model, Collection, etc.)

Keyboard Shortcuts

  • Scroll to Bottom Button - In toolbar for quick navigation
  • Floating Scroll to Top - Appears when scrolled down

๐Ÿ”ง Advanced Usage

Custom Labels

// Organize related dumps
dumpx($query)->label('DB Query');
dumpx($result)->label('Query Result');
dumpx($processed)->label('Processed Data');

// Filter by label in the viewer

Multiple Values with Same Label

// All values get the same label
dumpx($var1, $var2, $var3)->label('Test Variables');

Stopping Execution

// Use ->stop() to dump and halt execution
dumpx($criticalData)->label('Critical Error')->stop();

// Or chain it
dumpx($data)->label('Before Error')->stop();

Performance with Large Datasets

// Automatically truncates large collections
$users = User::all(); // 10,000 users

dumpx($users)->label('All Users');
// Shows warning and first 100 items

// Better approach:
dumpx(User::take(50)->get())->label('Sample Users');

๐ŸŽญ Use Cases

1. API Development

public function store(Request $request)
{
    dumpx($request->all())->label('Request Data');
    
    $validated = $request->validate([...]);
    dumpx($validated)->label('Validated Data');
    
    $user = User::create($validated);
    dumpx($user)->label('Created User');
    
    return response()->json($user);
}

2. Query Optimization

DB::listen(function ($query) {
    dumpx($query->sql)->label('Query: ' . $query->time . 'ms');
});

3. Event Debugging

Event::listen('*', function ($event, $payload) {
    dumpx([
        'event' => $event,
        'payload' => $payload
    ])->label('Event: ' . $event);
});

4. Job Debugging

class ProcessPodcast implements ShouldQueue
{
    public function handle()
    {
        dumpx($this->podcast)->label('Processing Podcast');
        
        // Process...
        
        dumpx($result)->label('Process Complete');
    }
}

๐Ÿ›ก๏ธ Security

Production Safety

The dump viewer is designed for development only:

// Disable in production
'enabled' => env('DUMPX_ENABLED', !app()->isProduction()),

// Or in .env
DUMPX_ENABLED=false

Route Protection

Add authentication middleware:

// config/dump-viewer.php
'middleware' => ['web', 'auth', 'admin'],

Access Control

Use custom middleware:

class DumpViewerAccess
{
    public function handle($request, Closure $next)
    {
        if (!app()->environment('local')) {
            abort(404);
        }
        
        return $next($request);
    }
}

// config/dump-viewer.php
'middleware' => ['web', DumpViewerAccess::class],

๐ŸŽฏ Tips & Best Practices

1. Use Labels Consistently

// Good: Organized and filterable
dumpx($query)->label('DB: User Query');
dumpx($result)->label('DB: Query Result');
dumpx($user)->label('User: Loaded');
dumpx($posts)->label('User: Posts');

// Bad: Hard to find and organize
dumpx($query);
dumpx($result);

2. Clean Up Regularly

// In your bootstrap or test setup
if (app()->environment('testing')) {
    app('dumpx')->clear();
}

3. Use in Tinker Workflows

// Keep viewer open in browser
// Run commands in Tinker
// Refresh browser to see dumps

4. Combine with Logs

// Dump for immediate visibility
dumpx($data)->label('Debug Point');

// Log for permanent record
Log::debug('Debug point', ['data' => $data]);

๐Ÿ”„ Comparison with Alternatives

Feature dumpx Ray Laravel Debugbar dump/dd
Web Interface โœ… Yes โŒ Desktop App โœ… Yes โŒ No
Persistent Storage โœ… Yes โœ… Yes โŒ Per Request โŒ No
Tinker Support โœ… Yes โœ… Yes โŒ No โœ… Yes
Real-time Updates โœ… Yes โœ… Yes โŒ No โŒ No
Labeling โœ… Yes โœ… Yes โŒ No โŒ No
Cost ๐Ÿ†“ Free ๐Ÿ’ฐ Paid ๐Ÿ†“ Free ๐Ÿ†“ Free
Setup โšก Easy ๐Ÿ“ฑ Desktop โšก Easy โœ… Built-in

๐Ÿ› Troubleshooting

Dumps Not Showing

1. Check if enabled:

php artisan tinker
>>> config('dump-viewer.enabled')

2. Check storage driver:

>>> config('dump-viewer.storage_driver')
// Should be 'file' for Tinker

3. Clear cache:

php artisan cache:clear
php artisan config:clear

4. Check file permissions:

chmod -R 775 storage/framework/cache

Tinker Not Working

1. Ensure file driver:

DUMPX_STORAGE_DRIVER=file

2. Test cache:

>>> Cache::store('file')->put('test', 'works', 60)
>>> Cache::store('file')->get('test')

3. Manually check dumps:

>>> app('dumpx')->all()

Route Not Found

1. Check route name:

>>> config('dump-viewer.route')

2. Clear route cache:

php artisan route:clear

3. List routes:

php artisan route:list | grep dump

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ“„ License

The MIT License (MIT). Please see License File for more information.

๐Ÿ‘ Credits

๐Ÿ”— Links

Made with โค๏ธ for the Laravel community