PHPackages                             theiconic/synopsis - 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. theiconic/synopsis

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

theiconic/synopsis
==================

PHP library to generate a language-agnostic description of PHP objects or values Edit

v1.0.5(6y ago)727.4k↓30%2[2 PRs](https://github.com/theiconic/synopsis/pulls)MITPHP

Since Feb 17Pushed 3y ago77 watchersCompare

[ Source](https://github.com/theiconic/synopsis)[ Packagist](https://packagist.org/packages/theiconic/synopsis)[ RSS](/packages/theiconic-synopsis/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (16)Used By (0)

synopsis
========

[](#synopsis)

PHP library to generate a language-agnostic description of PHP objects or values

[![Build Status](https://camo.githubusercontent.com/4a2fe794d2ff49322f1deb3e43e8a26d63c87c4b4538d50c425bf904683e4342/68747470733a2f2f7472617669732d63692e6f72672f74686569636f6e69632f73796e6f707369732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/theiconic/synopsis)[![Coverage Status](https://camo.githubusercontent.com/012bd12628baf7f3112c2bc46374aacdd5fe7eb9af24884d634b90568ba985b7/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f74686569636f6e69632f73796e6f707369732f62616467652e7376673f6272616e63683d6d617374657226743d32)](https://coveralls.io/github/theiconic/synopsis?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/6cab03265ffece4e719180174062e8a353167a742887af22cdab3712eea3ab4d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f74686569636f6e69632f73796e6f707369732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d617374657226743d31)](https://scrutinizer-ci.com/g/theiconic/synopsis/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/695b468dd4d940f597728ad9f684e5676c92fe61bc7966f6373667cef1edbc7a/68747470733a2f2f706f7365722e707567782e6f72672f74686569636f6e69632f73796e6f707369732f762f737461626c65)](https://packagist.org/packages/theiconic/synopsis)[![Total Downloads](https://camo.githubusercontent.com/362fbe690c4333c0efc204cec3914e2e9f96dd1f17034837e1f92968896ffbcb/68747470733a2f2f706f7365722e707567782e6f72672f74686569636f6e69632f73796e6f707369732f646f776e6c6f616473)](https://packagist.org/packages/theiconic/synopsis)[![License](https://camo.githubusercontent.com/a8628b5ab0b83b44c070bafc5f85cee5b9dc7846fc3fc1de4f2be4a18cc9435d/68747470733a2f2f706f7365722e707567782e6f72672f74686569636f6e69632f73796e6f707369732f6c6963656e7365)](https://packagist.org/packages/theiconic/synopsis)

Purpose
-------

[](#purpose)

This library can be used to generate language-agnostic descriptions of PHP variables or objects that can then be sent over a transport to another system, e.g. for debugging, monitoring and inspection purposes.

It generates a standardised representation that can easily be formatted in different ways.

E.g. possible use-cases are

- sending data together with log messages to a logging service
- sending debug data to a debugging/inspection tool
- pretty-formatting exceptions including their traces and the arguments in the calls of those traces
- output data on different channels (e.g. terminal, web, etc.) via standardised formatters

Setup (via Composer)
--------------------

[](#setup-via-composer)

Simply import the library in composer

```
composer require theiconic/synopsis

```

Basic Usage
-----------

[](#basic-usage)

You will need to start off by instantiating the factory

```
$factory = new TheIconic\Synopsis\Factory();
```

Now you can synopsise any value

```
class MyClass
{
    public $myProp = 1;
}

$myObject = new MyClass();
$myArray = [
    'string' => 'Hello World!',
    'integer' => 1,
    'boolean' = true,
];

$objectSynopsis = $factory->synopsize($myObject);
$arraySynopsis = $factory->synopsize($myArray);
```

Each call to `synopsize()` generates an `AbstractSynopsis`instance which describes the passed value.

Now use one of the formatters to format that data in a way that you can send over a transport or use by other components.

```
$formatter = new TheIconic\Synopsis\Formatter\ArrayFormatter();
$formatter->format($objectSynopsis);
/*
 * [
 *     'type' => 'MyClass',
 *     'length' => 1,
 *     'value' => ''
 *     'children' => [
 *         'myProp' => [
 *             'type' => 'integer',
 *             'length' => 1,
 *             'value' => 1,
 *         ]
 *     ]
 * ]
 */

$formatter->format($arraySynopsis);
/*
 * [
 *     'type' => 'array',
 *     'length' => 3,
 *     'value' => ''
 *     'children' => [
 *         'string' => [
 *             'type' => 'string',
 *             'length' => 12,
 *             'value' => 'Hello World!',
 *         ]
 *         'integer' => [
 *             'type' => 'integer',
 *             'length' => 1,
 *             'value' => 1,
 *         ],
 *         'string' => [
 *             'type' => 'boolean',
 *             'length' => 4,
 *             'value' => 'true',
 *         ]
 *     ]
 * ]
 */
```

Object Synopsis
---------------

[](#object-synopsis)

When synopsising objects, the factory checks if a custom Synopsis class is registered for the type of the object (i.e. it's class name). If so, then the special Synopsis type is used to synopsise the object and the result entirely depends on its implementation.

Custom object types can be registered via

```
$factory->addObjectType(MyClass::$class, MyClassSynopsis::class);
```

If no custom type is registered, default object synopsis is used.

A custom IteratorSynopsis type is registered for objects that implement Iterator or IteratorAggregate interfaces.

### Default Object Synopsis

[](#default-object-synopsis)

The default ObjectSynopsis implementation will inspect the object for any public properties. Each of those properties will be treated as the objects children and synopsised recursively.

The **length** will be the number of public properties found.

The objects class name will be used as the **type**.

To determine the **value**, the implementation will check for the presence and accessibility of any of the following methods in this order

- \_\_toSynopsisValue
- \_\_toString
- getId
- getName

The first method found will be executed and it's return value will be cast to string and used as the objects **value**.

### Default Iterator Synopsis

[](#default-iterator-synopsis)

The default IteratorSynopsis implementation will iterate through the object, synopsise any of the iteration values and add them as children.

Resource Synopsis
-----------------

[](#resource-synopsis)

When synopsising PHP resource pointers, the factory checks if a custom Synopsis class is registered for the type of resource (determined via `get_resource_type()`). If so, that type will be used.

By default, custom resource types are registered for some filetypes and streams and they will use `stream_get_meta_data()` to determine the resource uri and use it as the **value**.

Custom resource types can be registered via

```
$factory->addResourceType(MyClass::$class, MyClassSynopsis::class);
```

Exception Synopsis
------------------

[](#exception-synopsis)

Exceptions and their traces are synopsised in a special way adding additional properties to the synopsis objects.

These can be utilised in special Exception formatters.

### ExceptionSynopsis

[](#exceptionsynopsis)

- **type**: the exception type
- **value**: the exception message
- **length**: the length of the stack trace
- **line**: the line
- **file**: the file
- **children**: the synopsised stack trace

### TraceSynopsis

[](#tracesynopsis)

- **type**: a string representation of the full call
- **value**: a string representation of the file and line
- **length**: the number of call parameters
- **line**: the line
- **file**: the file
- **class**: the class name
- **function**: the function/method name
- **children**: the synopsised call parameters (if any)

Overriding default Synopsis implementations
-------------------------------------------

[](#overriding-default-synopsis-implementations)

To override the behaviour for any of the types, simply implement your own Synopsis class (inheriting from `AbstractSynopsis`) and register it with the factory via e.g.

```
$factory->addType('string', MyStringSynopsis::class);
```

License
-------

[](#license)

THE ICONIC Synopsis library for PHP is released under the MIT License.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 96.6% 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 ~107 days

Recently: every ~287 days

Total

12

Last Release

2195d ago

Major Versions

v0.4.1 → v1.0.02017-02-26

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1531431?v=4)[Jorge A. Borges Colina](/maintainers/jorgeborges)[@jorgeborges](https://github.com/jorgeborges)

![](https://www.gravatar.com/avatar/69ecbb50b3565cc040b7bb0431f1437f8b8358d906d4a23a71e47232dc3d49b3?d=identicon)[wyrfel](/maintainers/wyrfel)

---

Top Contributors

[![wyrfel](https://avatars.githubusercontent.com/u/425403?v=4)](https://github.com/wyrfel "wyrfel (56 commits)")[![ojhaujjwal](https://avatars.githubusercontent.com/u/4995501?v=4)](https://github.com/ojhaujjwal "ojhaujjwal (1 commits)")[![rafaelmonteiro](https://avatars.githubusercontent.com/u/1180413?v=4)](https://github.com/rafaelmonteiro "rafaelmonteiro (1 commits)")

---

Tags

debuggingdevelopmentintrospectionphpphp7synopsis

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/theiconic-synopsis/health.svg)

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

###  Alternatives

[symfony/stopwatch

Provides a way to profile code

2.8k387.2M918](/packages/symfony-stopwatch)[fruitcake/laravel-debugbar

PHP Debugbar integration for Laravel

19.1k662.9k29](/packages/fruitcake-laravel-debugbar)[jokkedk/webgrind

Webgrind is a Xdebug profiling web frontend in PHP5. It implements a subset of the features of kcachegrind and installs in seconds and works on all platforms. For quick'n'dirty optimizations it does the job.

3.3k193.0k](/packages/jokkedk-webgrind)[koriym/printo

An object graph visualizer.

1421.8M2](/packages/koriym-printo)[soloterm/dumps

A Laravel command to intercept dumps from your Laravel application.

125285.7k3](/packages/soloterm-dumps)[beyondcode/helo-laravel

HELO Laravel debug helper

90360.1k](/packages/beyondcode-helo-laravel)

PHPackages © 2026

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