Laravel Tools
Introduction
The features listed on this page are available only for applications built on the Laravel Framework and require the LaraDumps Laravel package to work properly.
Routes
You can use the routes()
method to list all Routes in a table format.
You may configure LaraDumps to exclude specific routes from the dump output.
ds()->routes();
Elloquent Model
You can use the model()
method to view Eloquent Model's Attributes and Relationships.
use App\Models\User;
$firstUser = User::first();
ds()->model($firstUser);
Stringable Macro
Displays the current string in a Stringable Macro
use Illuminate\Support\Str;
Str::of('Hello')
->append(' World')
->ds();
Collection Macro
Displays the current state of a Collection Macro
collect(['hello', 'world'])
->ds('original input')
->map(fn($string) => ucfirst($string))
->ds('capitalize result');
Query Macro
You can also chain a ds()
method before the query execution and, it will be dumped in the Desktop App:
use App\Models\User;
User::query()->where('name', 'Luan')
->ds()
->get();
WARNING
The macro feature doesn't require SQL Queries to be enabled in the configuration file.
Blade directive
For your convenience, LaraDums provides a @ds()
Blade directive.
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
@ds('Hello World')
Queries
To debug SQL queries, you must place the database call within the queriesOn()
and queriesOff()
methods.
For example:
use App\Models\User;
ds()->queriesOn('checking a user query');
User::query()->where('id', 20)->get();
ds()->queriesOff();
Ignoring Queries
Sometimes you may want to exclude certain queries from the debug dump. This could be helpful if you are looking for a specific query among a lot of others.
To ignore queries, you first need to publish the LaraDumps Laravel's config file. To do so, run the following command:
php artisan vendor:publish --tag=laradumps-config
Now, you can configure the recently created file config/laradumps.php
, adding the queries or route patterns that you do not want to see in your debug dump.
//config/laradumps.php
return [
'queries' => [
'ignore_sql_patterns' => [
'select name from `flights`',
],
'ignore_routes_patterns' => [
'horizon/*',
'telescope/*',
],
],
];
INFO
To Listen globally:
- In Desktop App, choose your project and toggle: QUERIES, or set
observers.queries
:true
in laradumps.yaml
Slow Queries
To monitor slow queries, just enable the "Slow Queries" option inside your project settings in the desktop app.
Alternatively, you may edit the option observers
> slow_queries
in your project's laradumps.yaml
file.
You may configure laradumps.yaml
and adjust the time limit that determines when a query's execution time is considered "slow". Just change the slow_queries
> threshold_in_ms
. The default time is 500 milliseconds.
#laradumps.yaml
observers:
slow_queries: true
slow_queries:
threshold_in_ms: 500
Table
You can use the table()
method to display dumps in a table with a built-in search bar.
To build a table, you can pass an instace of an Elloquent Model or any iterable $data
as the first argument. Next, you may add an optional string $name
for the table name.
use App\Models\User;
$allUsers = User::all(['id', 'name', 'email']);
ds()->table($allUsers, 'my users table');
Markdown
Displays the markdown rendered as HTML.
ds()->markdown('# hello world!');
Logs
The Desktop App will receive and dump Laravel Logs entries whenever you enable the Log feature.
use Illuminate\Support\Facades\Log;
Log::info('Your message', ['0' => 'Your Context']);
Log::error('Your message', ['0' => 'Your Context']);
INFO
To Listen globally:
- In Desktop App, choose your project and toggle: LOGS, or set
observers.logs
:true
in laradumps.yaml
Laravel 11 Log Context was supported
Mailable
Displays mail details and the HTML preview for an instance of a Illuminate\Mail\Mailable
class.
ds()->mailable(new \App\Mail\TestMail());
INFO
To Listen globally:
- In Desktop App, choose your project and toggle: MAIL, or set
observers.mail
:true
in laradumps.yaml
HTTP Requests
Captures and displays all the properties of HTTP Requests within the httpOn()
and httpOff()
methods.
use \Illuminate\Support\Facades\Http;
ds()->httpOn();
Http::get('https://jsonplaceholder.typicode.com/todos/1');
ds()->httpOff();
INFO
To Listen globally:
- In Desktop App, choose your project and toggle: HTTP, or set
observers.http
:true
in laradumps.yaml
Artisan Command
Captures and displays the called Artisan commands with their arguments, options and exit code.
use Illuminate\Support\Facades\Artisan;
ds()->commandsOn('running a command');
Artisan::call('inspire');
ds()->commandsOff();
INFO
To Listen globally:
- In Desktop App, choose your project and toggle: COMMANDS, or set
observers.commands
:true
in laradumps.yaml
Scheduled Commands
To monitor scheduled commands, just enable the "Scheduled Commands" option inside your project settings in the desktop app.
Alternatively, you may edit the option observers
> scheduled_commands
in your project's laradumps.yaml
file.
#laradumps.yaml
observers:
scheduled_commands: true
Gates
To monitor Gates activity, just enable the "Gate" option inside your project settings in the desktop app.
Alternatively, you may edit the option observers
> gate
in your project's laradumps.yaml
file.
#laradumps.yaml
observers:
gate: true
Jobs
To monitor and dump executed Jobs, just enable the "Jobs" option inside your project settings in the desktop app.
Alternatively, you may edit the option observers
> jobs
in your project's laradumps.yaml
file.
#laradumps.yaml
observers:
jobs: true
Cache
Captures and displays Cache information loaded within the cacheOn()
and cacheOff()
methods.
ds()->cacheOn('My cache');
// SET
cache()->set('feature', 'Cache Observer');
cache()->remember('name', 10, fn() => 'Anand Pilania');
// HIT
cache()->get('name');
// FORGET
cache()->forget('feature');
// MISSED
cache()->get('feature');
ds()->cacheOff();
INFO
To Listen globally:
- In Desktop App, choose your project and toggle: CACHE, or set
observers.cache
:true
in laradumps.yaml
Context
Displays the current state of Laravel Context
- Enable in the desktop app:
Settings → Layout tab → Show context (true)
Basic Usage
use Illuminate\Support\Facades\Context;
Context::set('key', 'value');
ds()->withContext();
Filtering Context by Key
Pass a key to display only the specified context value:
use Illuminate\Support\Facades\Context;
Context::set('key', 'value');
ds()->withContext('key');
INFO
Enable automatic context display for every dump by adding this to laradumps.yaml:
extra:
context: true