PHPackages                             symfony/polyfill-deepclone - 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. symfony/polyfill-deepclone

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

symfony/polyfill-deepclone
==========================

Symfony polyfill for the deepclone extension

v1.40.0(1mo ago)72.5M↑148.5%4MITPHPPHP &gt;=8.1

Since Apr 10Pushed 1mo agoCompare

[ Source](https://github.com/symfony/polyfill-deepclone)[ Packagist](https://packagist.org/packages/symfony/polyfill-deepclone)[ Docs](https://symfony.com)[ Fund](https://symfony.com/sponsor)[ GitHub Sponsors](https://github.com/fabpot)[ RSS](/packages/symfony-polyfill-deepclone/feed)WikiDiscussions 1.x Synced 3w ago

READMEChangelog (7)DependenciesVersions (8)Used By (4)

Symfony Polyfill / DeepClone
============================

[](#symfony-polyfill--deepclone)

This package provides a pure-PHP implementation of the functions and exception classes from the [deepclone extension](https://github.com/symfony/php-ext-deepclone):

- `deepclone_to_array(mixed $value, ?array $allowed_classes = null, bool $allow_named_closures = false): array`— converts any serializable PHP value graph into a pure array (only scalars and nested arrays, no objects).
- `deepclone_from_array(array $data, ?array $allowed_classes = null, bool $allow_named_closures = false): mixed`— rebuilds the value graph from the array, preserving object identity, references, cycles, and private property state.
- `DeepClone\NotInstantiableException` and `DeepClone\ClassNotFoundException`

When the native `deepclone` extension is loaded, this polyfill does nothing — the extension provides the same functions 4–5× faster.

The array representation preserves PHP's copy-on-write for strings and scalar arrays, making repeated cloning of a prototype significantly more memory efficient than `unserialize(serialize())`. It also serves as a cache-friendly serialization format: when dumped via `var_export()` into a `.php` file, OPcache maps the array into shared memory, making deserialization essentially free.

This is the same wire format used by Symfony's `VarExporter\DeepCloner`.

More information can be found in the [main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md).

License
=======

[](#license)

This library is released under the [MIT license](LICENSE).

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance91

Actively maintained with recent releases

Popularity49

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.9% 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 ~8 days

Total

8

Last Release

42d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/47313?v=4)[Fabien Potencier](/maintainers/fabpot)[@fabpot](https://github.com/fabpot)

---

Top Contributors

[![nicolas-grekas](https://avatars.githubusercontent.com/u/243674?v=4)](https://github.com/nicolas-grekas "nicolas-grekas (31 commits)")[![GromNaN](https://avatars.githubusercontent.com/u/400034?v=4)](https://github.com/GromNaN "GromNaN (1 commits)")

---

Tags

compatibilitycomponentdeepclonejavascriptpolyfillportableshimsymfonysymfony-componentsymfony-polyfillcompatibilityportablepolyfillshimdeepclone

### Embed Badge

![Health badge](/badges/symfony-polyfill-deepclone/health.svg)

```
[![Health](https://phpackages.com/badges/symfony-polyfill-deepclone/health.svg)](https://phpackages.com/packages/symfony-polyfill-deepclone)
```

###  Alternatives

[symfony/polyfill-mbstring

Symfony polyfill for the Mbstring extension

7.8k1.2B777](/packages/symfony-polyfill-mbstring)[symfony/polyfill-php72

Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions

4.7k688.6M35](/packages/symfony-polyfill-php72)[symfony/polyfill-intl-idn

Symfony polyfill for intl's idn\_to\_ascii and idn\_to\_utf8 functions

3.4k823.1M148](/packages/symfony-polyfill-intl-idn)[symfony/polyfill-intl-normalizer

Symfony polyfill for intl's Normalizer class and related functions

2.1k885.3M66](/packages/symfony-polyfill-intl-normalizer)[symfony/polyfill-php73

Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions

2.4k602.0M85](/packages/symfony-polyfill-php73)[symfony/polyfill-php80

Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions

1.7k868.7M558](/packages/symfony-polyfill-php80)

PHPackages © 2026

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