PHPackages                             berbeflo/modify-dump - 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. berbeflo/modify-dump

ActiveLibrary

berbeflo/modify-dump
====================

A small library that makes use of php8 attributes to modify the var\_dump output of objects

0.5(4y ago)05MITPHP

Since Sep 13Pushed 4y ago1 watchersCompare

[ Source](https://github.com/berbeflo/modify-dump)[ Packagist](https://packagist.org/packages/berbeflo/modify-dump)[ RSS](/packages/berbeflo-modify-dump/feed)WikiDiscussions main Synced 3d ago

READMEChangelogDependencies (3)Versions (12)Used By (0)

- [1. Modify Dump](#1-modify-dump)
    - [1.1. Motivation](#11-motivation)
    - [1.2. How it works](#12-how-it-works)
    - [1.3. Usage](#13-usage)
        - [1.3.1. Installation](#131-installation)
        - [1.3.2. First example](#132-first-example)
        - [1.3.3. Further examples](#133-further-examples)
    - [1.4. Features](#14-features)
        - [1.4.1. Filters](#141-filters)
        - [1.4.2. Formatters](#142-formatters)
        - [1.4.3. Statistics](#143-statistics)
        - [1.4.4. Extendibility](#144-extendibility)
        - [1.4.5. Not restricted to var\_dump](#145-not-restricted-to-var_dump)
- [2. Navigation](#2-navigation)

1. Modify Dump
==============

[](#1-modify-dump)

Enables easy modification of `var_dump` output with Attributes, that were introduced in PHP 8.

1.1. Motivation
---------------

[](#11-motivation)

I just wanted to play around with Attributes and this library was the first use-case that came into mind.

1.2. How it works
-----------------

[](#12-how-it-works)

PHP has a bunch of so called magic methods. These are object (or class) methods that get called under certain circumstances. Most of the time you'll come into touch with `__construct()`, which is called on object instantiation.
One of the less known magic methods is [\_\_debugInfo()](https://www.php.net/manual/en/language.oop5.magic.php#object.debuginfo) which is called on calling `var_dump()` on an object.
This library provides a [Trait](https://www.php.net/manual/en/language.oop5.traits.php) that overrides `__debugInfo()` and makes some magic based on the [Attributes](https://www.php.net/manual/en/language.attributes.overview.php) for the class and it's properties.

1.3. Usage
----------

[](#13-usage)

### 1.3.1. Installation

[](#131-installation)

`composer require berbeflo/modify-dump`

### 1.3.2. First example

[](#132-first-example)

Use the Trait `ModifiedDump` and tell it which properties to show:

```
