PHPackages                             secursus/var\_representation\_polyfill - 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. secursus/var\_representation\_polyfill

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

secursus/var\_representation\_polyfill
======================================

Polyfill for var\_representation: convert a variable to a string in a way that fixes the shortcomings of var\_export

1.0.0(4y ago)02.8k↓50%MITPHPPHP ^7.2.0|^8.0.0

Since Jun 26Pushed 4y agoCompare

[ Source](https://github.com/Secursus/var_representation_polyfill)[ Packagist](https://packagist.org/packages/secursus/var_representation_polyfill)[ RSS](/packages/secursus-var-representation-polyfill/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (8)Used By (0)

var\_representation\_polyfill
=============================

[](#var_representation_polyfill)

[![Build Status](https://github.com/TysonAndre/var_representation_polyfill/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/TysonAndre/var_representation_polyfill/actions/workflows/main.yml?query=branch%3Amain)[![License](https://camo.githubusercontent.com/2d1ae332ec2b19b642d2def615f9b595532d2edd3d91fd26e605287460fdc7e1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f5479736f6e416e6472652f7661725f726570726573656e746174696f6e5f706f6c7966696c6c2e737667)](https://github.com/TysonAndre/var_representation_polyfill/blob/main/LICENSE)[![Latest Stable Version](https://camo.githubusercontent.com/fdf1c9467670e89af9c175d6e09d8d4fa0235233a1d71a4d414b44a4443bc330/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f5479736f6e416e6472652f7661725f726570726573656e746174696f6e5f706f6c7966696c6c2e737667)](https://packagist.org/packages/TysonAndre/var_representation_polyfill)

[var\_representation\_polyfill](https://github.com/TysonAndre/var_representation_polyfill) is a polyfill for [https://pecl.php.net/var\_representation](https://pecl.php.net/var_representation)

This provides a polyfill for the function `var_representation(mixed $value, int $flags = 0): string`, which converts a variable to a string in a way that fixes the shortcomings of `var_export()`

See [the var\_representation PECL documentation](https://github.com/TysonAndre/var_representation) for more details

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

[](#installation)

```
composer require tysonandre/var_representation_polyfill

```

Usage
-----

[](#usage)

```
// uses short arrays, and omits array keys if array_is_list() would be true
php > echo var_representation(['a','b']);
[
  'a',
  'b',
]

// can dump everything on one line.
php > echo var_representation(['a', 'b', 'c'], VAR_REPRESENTATION_SINGLE_LINE);
['a', 'b', 'c']

php > echo var_representation("uses double quotes: \$\"'\\\n");
"uses double quotes: \$\"'\\\n"

// Can disable the escaping of control characters as of polyfill version 0.1.0
// (e.g. if the return value needs to be escaped again)
php > echo var_representation("has\nnewlines", VAR_REPRESENTATION_UNESCAPED);
'has
newlines'
php > echo json_encode("uses single quotes:\0\r\n\$\"'\\");
"uses single quotes:\u0000\r\n$\"'\\"
php > echo json_encode(var_representation("uses single quotes:\0\r\n\$\"'\\",
                                          VAR_REPRESENTATION_UNESCAPED));
"'uses single quotes:\u0000\r\n$\"\\'\\\\'"
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 92.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 ~34 days

Total

5

Last Release

1642d ago

Major Versions

0.1.1 → 1.0.02021-11-08

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/78356648?v=4)[secursus](/maintainers/secursus)[@Secursus](https://github.com/Secursus)

---

Top Contributors

[![TysonAndre](https://avatars.githubusercontent.com/u/1904430?v=4)](https://github.com/TysonAndre "TysonAndre (25 commits)")[![Secursus](https://avatars.githubusercontent.com/u/78356648?v=4)](https://github.com/Secursus "Secursus (2 commits)")

---

Tags

var\_exportvar\_representation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/secursus-var-representation-polyfill/health.svg)

```
[![Health](https://phpackages.com/badges/secursus-var-representation-polyfill/health.svg)](https://phpackages.com/packages/secursus-var-representation-polyfill)
```

###  Alternatives

[brick/varexporter

A powerful alternative to var\_export(), which can export closures and objects without \_\_set\_state()

19429.7M72](/packages/brick-varexporter)[tysonandre/var_representation_polyfill

Polyfill for var\_representation: convert a variable to a string in a way that fixes the shortcomings of var\_export

146.4M](/packages/tysonandre-var-representation-polyfill)[nexucis/es-index-helper

Elasticsearch Index Helper for php, which allows you to manage your indices without any downtime

1519.5k](/packages/nexucis-es-index-helper)

PHPackages © 2026

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