Get "PHP 8 in a Nutshell" (Soon PHP 8.5)
Amit Merchant
Amit Merchant

A blog on PHP, JavaScript, and more

A free and open-source alternative to Spatie's Ray to debug PHP applications

If you are a PHP developer, you might have heard about or worked with Spatie’s Ray, a popular debugging tool that allows you to send debug information from your PHP applications to a desktop app for easy inspection at some point.

This tool enables you to inspect and debug your code in real-time without disrupting the application’s flow. However, Ray is a paid product, and while it offers a free trial, it might not be suitable for everyone, especially for those who prefer open-source solutions.

Enter LaraDumps, a free and open-source alternative to Spatie’s Ray, which I recently discovered, that you can use to debug your PHP applications.

LaraDumps is inspired by Ray and offers similar functionality, allowing you to send debug information from your PHP applications to a desktop app for easy inspection.

So, a typical usage of LaraDumps would look like this. You can use the ds() (instead of dd() or dump()) global function to send data to the LaraDumps app. The function will be available once you install the package via Composer, which we will see in a bit.

use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    ds(['red', 'green', 'yellow'])->orange();
    
    return view('welcome');
});

And here’s what this looks like in the LaraDumps app.

ds() function in action

Pretty neat, right? You can even color-code your dumps by chaining methods like ->red(), ->green(), ->blue(), etc., to make them easily distinguishable just like in Ray.

To get started with LaraDumps, you need to follow these steps.

First, you need to download and install the LaraDumps desktop (client) app from here. The app is available for Windows, macOS, and Linux.

Once that is installed, you need to install the LaraDumps package in your PHP (or Laravel) application via Composer.

Note: Although the tool is primarily designed for Laravel, it can be used in any PHP application.

Here’s how you can install the package in your Laravel application via Composer.

composer require laradumps/laradumps ^4.0 --dev -W

And then configure the package by running the following command.

php artisan ds:init $(pwd)

This command will generate a file called laradumps.yaml in the root of your project that has all the necessary configurations to run LaraDumps correctly.

And if everything is set up correctly, you will notice that your project will be shown as in the image below, observing the “signal” icon, which means you’re ready to go.

This is just an introduction to LaraDumps, but there are many more features which you can explore on their official documentation.

Learn the fundamentals of PHP 8 (including 8.1, 8.2, 8.3, and 8.4), the latest version of PHP, and how to use it today with my new book PHP 8 in a Nutshell. It's a no-fluff and easy-to-digest guide to the latest features and nitty-gritty details of PHP 8. So, if you're looking for a quick and easy way to PHP 8, this is the book for you.

👋 Hi there! This is Amit, again. I write articles about all things web development. If you enjoy my work (the articles, the open-source projects, my general demeanour... anything really), consider leaving a tip & supporting the site. Your support is incredibly appreciated!

Comments?