2017 © Pedro Peláez
 

library inspect

PHP and Javascript library for inspecting variables and stack traces.

image

simplecomplex/inspect

PHP and Javascript library for inspecting variables and stack traces.

  • Saturday, June 16, 2018
  • by jacobfriis
  • Repository
  • 2 Watchers
  • 0 Stars
  • 95 Installations
  • PHP
  • 2 Dependents
  • 7 Suggesters
  • 0 Forks
  • 0 Open issues
  • 14 Versions
  • 73 % Grown

The README.md

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

Get Inspect

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

Principal methods and options

(int) $options

depth: max object/array recursion; DEPTH_DEFAULT/TRACE_DEPTH_DEFAULT, (*1)

(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

Do variable inspection, unless arg $subject is a throwable; then trace., (*2)

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

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

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

Force variable inspection, even if subject is a throwable., (*3)

$inspect->variable($var);

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

Trace exception or do back-trace., (*4)

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

Logging

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

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

Or use the Inspector's own chainable PSR logger-like method:, (*6)

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

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

Javascript

(object) options, (*8)

  • (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:, (*9)

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

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., (*10)

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., (*11)

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., (*12)

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., (*13)

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., (*14)

Used in - extended by - Drupal

The backbone of the Drupal Inspect module 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., (*15)

MIT licensed

License and copyright. Explained., (*16)

Requirements

  • PHP >=8.1

The Versions

16/06 2018

dev-master

9999999-dev https://github.com/simplecomplex/inspect

PHP and Javascript library for inspecting variables and stack traces.

  Sources   Download

MIT

The Requires

 

by Jacob Friis Mathiasen

php dump developer trace inspect

16/06 2018

dev-develop

dev-develop https://github.com/simplecomplex/inspect

PHP and Javascript library for inspecting variables and stack traces.

  Sources   Download

MIT

The Requires

 

by Jacob Friis Mathiasen

php dump developer trace inspect

16/06 2018

2.2.4

2.2.4.0 https://github.com/simplecomplex/inspect

PHP and Javascript library for inspecting variables and stack traces.

  Sources   Download

MIT

The Requires

 

by Jacob Friis Mathiasen

php dump developer trace inspect

04/06 2018

2.2.3

2.2.3.0 https://github.com/simplecomplex/inspect

PHP and Javascript library for inspecting variables and stack traces.

  Sources   Download

MIT

The Requires

 

by Jacob Friis Mathiasen

php dump developer trace inspect

01/05 2018

2.2.2

2.2.2.0 https://github.com/simplecomplex/inspect

PHP and Javascript library for inspecting variables and stack traces.

  Sources   Download

MIT

The Requires

 

by Jacob Friis Mathiasen

php dump developer trace inspect

25/04 2018

2.2.1

2.2.1.0 https://github.com/simplecomplex/inspect

PHP and Javascript library for inspecting variables and stack traces.

  Sources   Download

MIT

The Requires

 

by Jacob Friis Mathiasen

php dump developer trace inspect

07/04 2018

2.2

2.2.0.0 https://github.com/simplecomplex/inspect

PHP and Javascript library for inspecting variables and stack traces.

  Sources   Download

MIT

The Requires

 

by Jacob Friis Mathiasen

php dump developer trace inspect

26/03 2018

dev-inspecttolog

dev-inspecttolog https://github.com/simplecomplex/inspect

PHP and Javascript library for inspecting variables and stack traces.

  Sources   Download

MIT

The Requires

 

by Jacob Friis Mathiasen

php dump developer trace inspect

24/09 2017

2.1

2.1.0.0 https://github.com/simplecomplex/inspect

PHP and Javascript library for inspecting variables and stack traces.

  Sources   Download

MIT

The Requires

 

by Jacob Friis Mathiasen

php dump developer trace inspect

13/07 2017

2.0

2.0.0.0 https://github.com/simplecomplex/inspect

PHP and Javascript library for inspecting variables and stack traces.

  Sources   Download

MIT

The Requires

 

by Jacob Friis Mathiasen

php dump developer trace inspect

28/05 2017

dev-2.x-dev

dev-2.x-dev https://github.com/simplecomplex/inspect

Inspect is a PHP and Javascript library for inspecting variables and stack traces.

  Sources   Download

MIT

The Requires

 

by Jacob Friis Mathiasen

dump developer trace inspect

01/05 2016

1.1

1.1.0.0 https://github.com/simplecomplex/inspect

Inspect is a PHP and Javascript library for inspecting variables and stack traces.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Jacob Friis Mathiasen

dump developer trace inspect

01/05 2016

dev-dev-1.x

dev-dev-1.x https://github.com/simplecomplex/inspect

Inspect is a PHP and Javascript library for inspecting variables and stack traces.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Jacob Friis Mathiasen

dump developer trace inspect

12/07 2015

1.0

1.0.0.0 https://github.com/simplecomplex/inspect

Inspect is a PHP and Javascript library for inspecting variables and stack traces.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Jacob Friis Mathiasen

dump developer trace inspect