Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sebastianbergmann/object-graph
Provides useful operations on PHP object graphs
https://github.com/sebastianbergmann/object-graph
object php visualization
Last synced: about 1 month 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 7 years ago)
- Default Branch: main
- Last Pushed: 2024-08-13T09:29:14.000Z (3 months ago)
- Last Synced: 2024-10-01T08:01:19.475Z (about 1 month ago)
- Topics: object, php, visualization
- Language: PHP
- Homepage:
- Size: 23 MB
- Stars: 459
- Watchers: 22
- Forks: 14
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# sebastian/object-graph
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.1-8892BF.svg?style=flat-square)](https://php.net/)
[![Latest Stable Version](https://img.shields.io/packagist/v/sebastian/object-graph.svg?style=flat-square)](https://packagist.org/packages/sebastian/object-graph)
[![CI Status](https://github.com/sebastianbergmann/object-graph/workflows/CI/badge.svg)](https://github.com/sebastianbergmann/object-graph/actions)
[![Code Coverage](https://img.shields.io/codecov/c/github/sebastianbergmann/object-graph.svg?style=flat-square)](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);
```![Screenshot](example/example.svg)
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`.