PHPackages                             ultimatelemon/lens - 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. ultimatelemon/lens

ActiveComposer-plugin[Debugging &amp; Profiling](/categories/debugging)

ultimatelemon/lens
==================

Lens - stuur debug-payloads naar de Lens desktop-app

v1.2.0(1mo ago)03↑2900%MITPHPPHP &gt;=8.0

Since Jun 24Pushed 1mo agoCompare

[ Source](https://github.com/ultimatelemon/Lens)[ Packagist](https://packagist.org/packages/ultimatelemon/lens)[ RSS](/packages/ultimatelemon-lens/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (5)Used By (0)

Lens (PHP client)
=================

[](#lens-php-client)

Send debug payloads from your PHP or Laravel project straight to the **Lens desktop app**. Instead of polluting your response with `dd()` or `var_dump()`, use `lens(...)` to send neatly rendered data to a separate window, with syntax highlighting, labels, colors and the line it came from.

```
lens('hello');
lens($user)->color('green')->label('Signed-in user');
lens(['order' => $order, 'total' => $amount]);
```

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

[](#requirements)

- PHP 8.0 or higher (with `ext-curl` and `ext-json`)
- The **Lens desktop app** must be running, it receives and displays the payloads. (Separate application; listens on `127.0.0.1:23600` by default.)

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

[](#installation)

Install as a **dev dependency** (it's a debugging tool, just like `dd()`):

```
composer require ultimatelemon/lens --dev
```

In Laravel the package is auto-discovered. Nothing else to configure.

> **Note:** because this is a dev dependency, the `lens()` helper does not exist in production (`composer install --no-dev`). So don't leave `lens()` calls in code that ships to production - treat it like `dd()`. See [Prevent commits with lens()](#prevent-commits-with-lens).

Usage
-----

[](#usage)

The global `lens()` helper is available everywhere:

```
// A single value
lens('checkpoint reached');

// Multiple values at once
lens($request->all(), $user, $total);

// Chaining: label and color
lens($order)->label('New order')->color('green');

// Clear the screen
\UltimateLemon\Lens\Lens::clear();
```

Available colors: `red`, `green`, `blue`, `orange`, `purple`, `gray`.

In Blade views you can use the `@lens` directive:

```
@lens($user)
@lens(['cart' => $cart], 'Checkout')
```

Exceptions
----------

[](#exceptions)

Exceptions show up as a red item with an expandable stack trace:

```
lens($exception);                          // a Throwable is detected automatically
\UltimateLemon\Lens\Lens::exception($e);   // explicit
```

In Laravel, reported exceptions are sent to Lens **automatically**. Disable it with:

```
LENS_CATCH_EXCEPTIONS=false
```

Laravel streams
---------------

[](#laravel-streams)

Stream Laravel internals straight to Lens. Toggle per environment in your `.env`:

```
LENS_QUERIES=true   # every DB query (SQL + bindings + time)
LENS_MAILS=true     # outgoing mails, with a rendered HTML preview
LENS_JOBS=true      # queue jobs (processing / processed / failed)
LENS_EVENTS=true    # application events (framework noise filtered out)
LENS_MODELS=true    # Eloquent created / updated / deleted / restored
```

Or enable them in code:

```
\UltimateLemon\Lens\Lens::showQueries();
\UltimateLemon\Lens\Lens::showMails();   // shows the email's HTML in a sandboxed preview
\UltimateLemon\Lens\Lens::showJobs();
\UltimateLemon\Lens\Lens::showEvents();
\UltimateLemon\Lens\Lens::showModels();
```

Pause execution
---------------

[](#pause-execution)

Pause your code until you click **Continue** or **Stop** in the Lens app:

```
\UltimateLemon\Lens\Lens::pause();
```

Returns immediately if Lens is disabled or the app is not running, so it never hangs your app.

Artisan commands
----------------

[](#artisan-commands)

```
php artisan lens:test           # send a test payload to the Lens app
php artisan lens:check          # scan for leftover lens() calls
php artisan lens:check --staged # only staged files (for pre-commit)
php artisan lens:install-hooks  # install a git pre-commit hook
```

Prevent commits with lens()
---------------------------

[](#prevent-commits-with-lens)

`lens:check` scans for leftover `lens()` calls and returns exit code 1 when it finds any (useful in CI). A git pre-commit hook then automatically blocks any commit containing a `lens()` call.

### Automatic (recommended)

[](#automatic-recommended)

The package installs the pre-commit hook **by itself** on `composer install`/`update`, but Composer requires your one-time consent for this. Add this to your project's `composer.json`:

```
"config": {
  "allow-plugins": {
    "ultimatelemon/lens": true
  }
}
```

The hook is only installed:

- in **dev** (never on `composer install --no-dev` / production / CI deploy);
- in a **Laravel project** (an `artisan` file must be present);
- when there is a `.git` directory and **no** pre-commit hook exists yet (an existing hook is never overwritten).

### Manual

[](#manual)

```
php artisan lens:install-hooks
```

If a pre-commit hook already exists, use `--force` or add this line yourself:

```
php artisan lens:check --staged || exit 1
```

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

[](#configuration)

### Laravel

[](#laravel)

Optionally publish the config file:

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

Or configure everything through your `.env`:

```
LENS_ENABLED=true
LENS_HOST=127.0.0.1
LENS_PORT=23600
```

### Disable in production

[](#disable-in-production)

Simply set:

```
LENS_ENABLED=false
```

All `lens()` calls then become no-ops, no network traffic, no overhead touching your app.

### Without Laravel (plain PHP)

[](#without-laravel-plain-php)

```
require __DIR__ . '/vendor/autoload.php';

use UltimateLemon\Lens\Lens;

Lens::configure('127.0.0.1', 23600); // optional; these are the defaults
lens('works without a framework too');
```

How it works
------------

[](#how-it-works)

`lens()` builds a JSON payload and makes a short HTTP POST to the Lens desktop app (`http://LENS_HOST:LENS_PORT`). If that fails (app not open, timeout) the error is silently ignored, debugging should never break your application.

License
-------

[](#license)

MIT, see [LICENSE](LICENSE).

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance90

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

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 ~0 days

Total

4

Last Release

45d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3a42e3b3cd85be5ddd844ec7b3b1c0393cf6e2d834e9e63462dc0158f75e02ee?d=identicon)[UltimateLemon](/maintainers/UltimateLemon)

---

Tags

laraveldebugdumpdebuggingdeveloper-toolslens

### Embed Badge

![Health badge](/badges/ultimatelemon-lens/health.svg)

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

###  Alternatives

[xrdebug/php

PHP client library for xrDebug

23826.2k3](/packages/xrdebug-php)[jbzoo/jbdump

Script for debug and dump PHP variables and other stuff. This tool is a nice replacement for print\_r() and var\_dump() functions.

191.1M3](/packages/jbzoo-jbdump)

PHPackages © 2026

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