https://github.com/sebastianbergmann/object-graph
Provides useful operations on PHP object graphs
https://github.com/sebastianbergmann/object-graph
object php visualization
Last synced: 2 months ago
JSON representation
Provides useful operations on PHP object graphs
- Host: GitHub
- URL: https://github.com/sebastianbergmann/object-graph
- Owner: sebastianbergmann
- License: bsd-3-clause
- Created: 2017-03-15T15:04:36.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2025-04-13T07:27:35.000Z (3 months ago)
- Last Synced: 2025-04-13T16:08:10.564Z (3 months ago)
- Topics: object, php, visualization
- Language: PHP
- Homepage:
- Size: 23.9 MB
- Stars: 456
- Watchers: 21
- Forks: 14
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# sebastian/object-graph
[](https://php.net/)
[](https://packagist.org/packages/sebastian/object-graph)
[](https://github.com/sebastianbergmann/object-graph/actions)
[](https://codecov.io/gh/sebastianbergmann/object-graph)Provides useful operations on PHP object graphs.
## Installation
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
```
composer require sebastian/object-graph
```If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:
```
composer require --dev sebastian/object-graph
```## Usage
### Object Graph Visualization with GraphViz
```php
add(new ShoppingCartItem('Foo', new Money(123, new Currency('EUR')), 1));
$cart->add(new ShoppingCartItem('Bar', new Money(456, new Currency('EUR')), 1));object_graph_dump('graph.png', $cart);
```
The `object_graph_dump()` function supports the [DOT Graph Description Language](https://en.wikipedia.org/wiki/DOT_(graph_description_language)) (`.dot`), [Portable Document Format](https://en.wikipedia.org/wiki/Portable_Document_Format) (`.pdf`), [Portable Network Graphics](https://en.wikipedia.org/wiki/Portable_Network_Graphics) (`.png`), and [Scalable Vector Graphics](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics) (`.svg`) output formats.
The generation of PDF, PNG, and SVG files requires the [GraphViz](http://www.graphviz.org/) `dot` binary to be on the `$PATH`.