Search by

muradcade / laravel_peek

MuradCade

Send debug output from Laravel/PHP to the Peek desktop app

Package info

github.com/MuradCade/laravel_peek

Homepage

Issues

pkg:composer/muradcade/laravel_peek

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

v1.0.1 2026-12-06 16:17 UTC

This package is auto-updated.

Last update: 2026-12-06 16:18:14 UTC


README

Send values, SQL queries, stack traces and exceptions from your Laravel app straight to the Peek desktop app, without littering your browser or API responses with dd() output.

peek($user);                    // dump anything
peek_label('Cart total', $sum); // dump with a label
peek_trace();                   // who called this?

Peek is fire-and-forget: if the Peek app is closed, your application keeps running at full speed and nothing breaks.

Features

  • 🔍 peek() helper: dump one or many values; returns the first value so it can be chained
  • 🏷️ Labels: tag dumps so you can find them quickly
  • 🧭 Origin tracking: every message records the file and line it came from
  • 🗄️ SQL query logging: SQL, bindings and execution time (opt-in)
  • 🚨 Exception reporting: reported exceptions appear in Peek (opt-in)
  • 🪜 Stack traces: peek_trace() sends a compact call stack
  • 🛡️ Safe by default: disabled automatically when APP_DEBUG=false
  • ⚡ Non-blocking: 300 ms hard timeout, errors are silenced

Requirements

  • PHP 8.0+
  • Laravel 9.x or newer (uses illuminate/support)
  • PHP extensions: curl, json
  • The Peek desktop app, listening on 127.0.0.1:23517

Installation

Install as a development dependency:

composer require --dev muradcade/laravel_peek

The service provider and helper functions are registered automatically through Laravel package auto-discovery. No further setup is needed. .

Usage

Dump values

peek($order);
peek($a, $b, $c);   // multiple values, each sent separately

peek() returns its first argument, so you can drop it into an expression:

$total = peek($cart->total()) * 1.2;

Labelled dumps

peek_label('Payload', $request->all());

Returns the value, so it is chainable too.

Stack traces

peek_trace();

Sends the current call stack (class, method, file and line for each frame) to Peek.

Using the class directly

The helpers are thin wrappers around Peek\Peek:

use Peek\Peek;

Peek::send('dump', $value, 'My label');

Logging SQL queries

Add to your .env:

PEEK_QUERIES=true

Every query is sent with its SQL, bindings and execution time in milliseconds.

Reporting exceptions

PEEK_EXCEPTIONS=true

Any exception passed through Laravel's exception reporter is sent to Peek, including class, message, file and line. Your existing exception handling is not changed.

Configuration

Peek is configured through environment variables:

Variable Default Description
PEEK_ENABLED value of APP_DEBUG Master switch for the query and exception listeners
PEEK_QUERIES false Send every SQL query to Peek
PEEK_EXCEPTIONS false Send reported exceptions to Peek

To point Peek at a different host or port, set the URL at runtime, for example in a service provider:

\Peek\Peek::$url = 'http://127.0.0.1:23517/';

How it works

Each call sends a JSON POST to the Peek app:

{
  "type": "dump",
  "label": "Cart total",
  "time": "14:32:07",
  "origin": "CartController.php:42",
  "data": { }
}
Field Description
type dump, query, exception or trace
label Optional label (null if none)
time Time sent, H:i:s
origin file.php:line of the calling code
data The normalized value

Values are normalized before sending:

  • Objects become arrays with a __class key (uses toArray() when available, otherwise all properties including private and protected ones)
  • Exceptions are reduced to class, message and file:line
  • Closures appear as {"__class": "Closure"}
  • Resources become resource(type)
  • Non-finite floats (INF, NAN) become strings
  • Nesting deeper than 6 levels is truncated

Production safety

Peek is intended for local development only.

  • Install it with --dev
  • Leave APP_DEBUG=false in production, which disables the listeners
  • Remove stray peek() calls before deploying. If the helper is not installed (for example composer install --no-dev), calls to peek() will throw an undefined function error

Payloads are sent over plain HTTP to 127.0.0.1 and never leave your machine.

Note on config caching: Peek reads its settings with env(). If you run php artisan config:cache locally, env() returns null outside of config files, so the defaults apply. Run php artisan config:clear during development.

Troubleshooting

Nothing shows up in Peek

  1. Make sure the Peek app is running and listening on port 23517
  2. Check APP_DEBUG=true or PEEK_ENABLED=true
  3. For queries or exceptions, confirm PEEK_QUERIES / PEEK_EXCEPTIONS are true
  4. If you use Docker, Sail or a VM, 127.0.0.1 refers to the container. Set Peek::$url to a host-reachable address such as http://host.docker.internal:23517/

Large objects look truncated

Depth is limited to 6 levels to keep payloads small.

Contributing

Issues and pull requests are welcome. Please open an issue first to discuss larger changes.

License

Released under the MIT License.