PHPackages                             simplecomplex/inspect - 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. simplecomplex/inspect

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

simplecomplex/inspect
=====================

PHP and Javascript library for inspecting variables and stack traces.

4.0.0(2y ago)0169.4k↓70%2MITPHPPHP &gt;=8.1

Since Jul 12Pushed 2y ago2 watchersCompare

[ Source](https://github.com/simplecomplex/inspect)[ Packagist](https://packagist.org/packages/simplecomplex/inspect)[ Docs](https://github.com/simplecomplex/inspect)[ RSS](/packages/simplecomplex-inspect/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (28)Used By (2)

(PHP+JS) Inspect: variable dumps and stack traces
-------------------------------------------------

[](#phpjs-inspect-variable-dumps-and-stack-traces)

- [Description](#Description)
- [License](#MIT-licensed)
- [Requirements](#Requirements)

### Get Inspect

[](#get-inspect)

```
// If dependency injection container exists.
$inspect = $container->get('inspect');
// Otherwise use maker.
$inspect = \SimpleComplex\Inspect\Inspect::getInstance();
```

### Principal methods and options

[](#principal-methods-and-options)

#### (int) $options

[](#int-options)

`depth`: max object/array recursion; DEPTH\_DEFAULT/TRACE\_DEPTH\_DEFAULT

#### (array) $options

[](#array-options)

- (int) `depth`: max object/array recursion; DEPTH\_DEFAULT/TRACE\_DEPTH\_DEFAULT
- (int) `limit`: max trace frame; TRACE\_LIMIT\_DEFAULT
- (int) `code`: error code, overrides exception code; none
- (int) `truncate`: string truncation; TRUNCATE\_DEFAULT
- (arr) `skip_keys`: skip those object/array keys; none
- (arr) `needles`: replace in strings; NEEDLES/NEEDLES\_ESCAPE\_HTML
- (arr) `replacers`: replace in strings; REPLACERS/REPLACERS\_ESCAPE\_HTML
- (bool) `escape_html`: replace in strings; ESCAPE\_HTML
- (int) `output_max`: replace in strings; OUTPUT\_DEFAULT
- (int) `exectime_percent`: replace in strings; EXEC\_TIMEOUT\_DEFAULT
- (bool) `rootdir_replace`: replace root dir in strings; ROOT\_DIR\_REPLACE
- (int) `wrappers`: number of wrapping functions/methods, to be hidden; zero

#### inspect($subject, $options = \[\]): Inspector

[](#inspectsubject-options---inspector)

Do variable inspection, unless arg $subject is a throwable; then trace.

```
$var = 'what is this?'; $xcptn = new \Exception('Doh');

// Inspect:
$inspect->inspect($var);
// Trace:
$inspect->inspect($xcptn);
```

#### variable($subject, $options = \[\]): Inspector

[](#variablesubject-options---inspector)

Force variable inspection, even if subject is a throwable.

```
$inspect->variable($var);
```

#### trace($throwableOrNull, $options = \[\]): Inspector

[](#tracethrowableornull-options---inspector)

Trace exception or do back-trace.

```
// Trace exception:
$inspect->trace($xcptn);
// Do back-trace:
$inspect->trace(null);
```

#### Logging

[](#logging)

The Inspector returned by inspect|variable|trace() is stringable. Pass it directly to a PSR logger:

```
$logger->debug('Darned ding' . "\n" . $inspect->variable($var));
```

Or use the Inspector's own chainable PSR logger-like method:

**log($level = 'debug', $message = '', array $context = \[\]): void**

```
$inspect->variable($var)->log('debug', 'darned ding');
```

### Javascript

[](#javascript)

(object) options

- (string) `message`: content headline and options as string also interprets to message (except when 'protos'/'func\_body')
- (integer) `depth`: array|object recursion max (default 10, max 10)
- (boolean) `protos`: analyze prototypal properties too
- (boolean) `func_body`: print bodies of functions
- (string) `type`: default 'inspect'/'inspect trace'
- (string) `severity`: default 'debug'/'error'

To console:

```
window.inspect(u, options);
window.inspect.trace(er, options);
```

### Description

[](#description)

Produces tidy and informative variable dumps and exception/back traces.
Tailormade and ready for logging - the inspect/variable/trace() methods return a stringable object.

#### Safe

[](#safe)

The inspector and tracer guarantee not to fail. A simple PHP:var\_dump() is prone to raise a PHP error if you dump a large or complex array like $GLOBALS, due to references (recursion).
Inspect limits it's recursion into sub arrays/objects. It also keeps track of how large an output it produces. And it finally makes sure that max execution time doesn't get exceeded.

#### Secure

[](#secure)

Inspect hides the values of array/object buckets named 'pw', 'pass' and 'password'.
And values of other sensitives can be hidden using 'skip\_keys' option.

#### PHP and Javascript

[](#php-and-javascript)

Inspect consists of a PHP library for serverside inspection and tracing, and a Javascript library for clientside ditto.
NB: The Javascript library has not been maintained since 2015.

#### Maturity

[](#maturity)

The library has existed in various forms since 2010. The core has been refined continuously whereas the wrapping has evolved from a rather oldschool OOP pattern over a solid but non-orthodox Drupal style, to well-behaved PSR/Composer patterns.

#### Used in - *extended by* - Drupal

[](#used-in---extended-by---drupal)

The backbone of the [Drupal Inspect module](https://drupal.org/project/inspect) is SimpleComplex Inspect. The Drupal module (D7 as well as D8) extends Inspect to accomodate to the context - that is: uses Drupal's APIs and features when it makes sense.

### MIT licensed

[](#mit-licensed)

[License and copyright](https://github.com/simplecomplex/inspect/blob/master/LICENSE). [Explained](https://tldrlegal.com/license/mit-license).

### Requirements

[](#requirements)

- PHP &gt;=8.1

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 99.4% of commits — single point of failure

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

Recently: every ~0 days

Total

22

Last Release

972d ago

Major Versions

1.1 → 2.02017-07-12

2.3.1 → 3.0.0-beta2020-06-01

3.1.1 → 4.0.0-beta12023-11-02

PHP version history (4 changes)1.0PHP &gt;=5.3.0

2.0PHP &gt;=7.0

3.0.0-betaPHP &gt;=7.2

4.0.0-beta1PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/cc4dc35e0d2b8e4619ae2fe2d083cb3c64b09127ecb318c3909025fc0aae1e7f?d=identicon)[jacobfriis](/maintainers/jacobfriis)

---

Top Contributors

[![jacobfriis](https://avatars.githubusercontent.com/u/3807905?v=4)](https://github.com/jacobfriis "jacobfriis (170 commits)")[![simplecomplex](https://avatars.githubusercontent.com/u/10960036?v=4)](https://github.com/simplecomplex "simplecomplex (1 commits)")

---

Tags

inspectionphpphp7psrtracephpdumptracedeveloperinspect

### Embed Badge

![Health badge](/badges/simplecomplex-inspect/health.svg)

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

###  Alternatives

[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.

211.1M3](/packages/jbzoo-jbdump)[php-sage/sage

☯ Insightful PHP debugging assistant.

5748.2k7](/packages/php-sage-sage)[koriym/xdebug-mcp

Universal PHP Xdebug MCP Server with AI-optimized debugging support

5227.1k1](/packages/koriym-xdebug-mcp)[sunra/dbug

Most beautiful variable dump library for PHP (ColdFusion like style)

1071.7k8](/packages/sunra-dbug)[thehocinesaad/laravel-error-ai

This package adds Ask AI button to the error page.

2226.9k](/packages/thehocinesaad-laravel-error-ai)

PHPackages © 2026

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