PHPackages                             frostaly/var-exporter - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. frostaly/var-exporter

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

frostaly/var-exporter
=====================

The frostaly VarExporter component.

030PHP

Since Jul 13Pushed 3y ago1 watchersCompare

[ Source](https://github.com/frostaly/var-exporter)[ Packagist](https://packagist.org/packages/frostaly/var-exporter)[ RSS](/packages/frostaly-var-exporter/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

VarExporter Component
=====================

[](#varexporter-component)

[![](https://avatars.githubusercontent.com/u/95505865)](https://avatars.githubusercontent.com/u/95505865)

The VarExporter component provides a simple alternative to PHP's `var_export()`.

[![Source Code](https://camo.githubusercontent.com/b12f8c8f84769802ad19d42611083a835c9ad20b890f0ac02635d5025e23ca74/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736f757263652d66726f7374616c792f7661722d2d6578706f727465722d626c75652e737667)](https://github.com/frostaly/var-exporter)[![CI Status](https://github.com/frostaly/var-exporter/workflows/Build/badge.svg)](https://github.com/frostaly/var-exporter/actions?query=workflow%3A%22Build%22)[![Code Quality](https://camo.githubusercontent.com/7699a5bea6dd8bac52c34b3e35aaa95a5571dcf092b5f77088f42c85f12edb03/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f66726f7374616c792f7661722d6578706f727465722f6261646765732f7175616c6974792d73636f72652e706e67)](https://scrutinizer-ci.com/g/frostaly/var-exporter/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/73bfb4e77526c638f10b0b86d5e0606cb7d317fe50a7082e84de1c41170433a9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f66726f7374616c792f7661722d6578706f727465722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/frostaly/var-exporter/?branch=master)[![Software License](https://camo.githubusercontent.com/f48c4e27e13201a3bd84815224f51b584618b5f0fda213ca685705c813cf5b9d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d47504c2d3030383837372e737667)](https://github.com/frostaly/var-exporter/blob/master/LICENSE)

Requirements
------------

[](#requirements)

- This library requires PHP 8.1 or later.

Installation
------------

[](#installation)

This library is installable via [composer](https://getcomposer.org/):

```
$ composer require frostaly/var-exporter

```

Quickstart
----------

[](#quickstart)

The VarExporter works like `var_export()`. It takes any value and returns the PHP code representation for that value:

```
echo Frostaly\VarExporter\VarExporter::export(['foo' => 'bar', 'baz' => [1.0, true, null]]);
```

```
[
    'foo' => 'bar',
    'baz' => [
        1.0,
        true,
        null,
    ]
]
```

Exporting Objects
-----------------

[](#exporting-objects)

VarExporter determines the most appropriate method to export your object using the registered encoders.

### StdClassEncoder

[](#stdclassencoder)

It exports stdClass as an array to object cast.

```
(object) [
    'foo' => 'Hello'
    'bar' => 'World',
]
```

### SetStateEncoder

[](#setstateencoder)

It uses the `__set_state()` method just like `var_export` would do:

```
Namespace\CustomClass::__set_state([
    'foo' => 'Hello'
    'bar' => 'World',
])
```

### SerializeEncoder

[](#serializeencoder)

It uses `__serialize()` and `__unserialize()` methods and the `Frostaly\VarExporter\Instantiator` class:

```
Frostaly\VarExporter\Instantiator::unserialize(Namespace\CustomClass::class, [
    'foo' => 'Hello',
    'bar' => 'World',
]);
```

### ObjectEncoder

[](#objectencoder)

It can encode any custom object using either its constructor and named arguments or the `Frostaly\VarExporter\Instantiator` class:

```
new Namespace\CustomClass(
    foo: 'Hello',
    bar: 'World',
)
```

```
Frostaly\VarExporter\Instantiator::construct(Namespace\CustomClass::class, [
    'foo' => 'Hello',
    'bar' => 'World',
]);
```

Contributing
------------

[](#contributing)

Anyone can contribute to this repository. Please do so by posting issues when you've found something that is unexpected or sending a pull request for improvements.

###  Health Score

16

—

LowBetter than 4% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity26

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/33b8756e33d5740413b0b89fdd828eaeb006651643cfd53d2b36468fac6f0773?d=identicon)[Aksiome](/maintainers/Aksiome)

---

Top Contributors

[![aksiome](https://avatars.githubusercontent.com/u/54895777?v=4)](https://github.com/aksiome "aksiome (6 commits)")

### Embed Badge

![Health badge](/badges/frostaly-var-exporter/health.svg)

```
[![Health](https://phpackages.com/badges/frostaly-var-exporter/health.svg)](https://phpackages.com/packages/frostaly-var-exporter)
```

###  Alternatives

[dompdf/php-font-lib

A library to read, parse, export and make subsets of different types of font files.

1.8k45.3M11](/packages/dompdf-php-font-lib)[illuminate/config

The Illuminate Config package.

10944.5M2.5k](/packages/illuminate-config)[consolidation/site-alias

Manage alias records for local and remote sites.

6152.1M28](/packages/consolidation-site-alias)

PHPackages © 2026

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