Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Polyfill Deepclone Laravel Package

symfony/polyfill-deepclone

Pure-PHP implementation of the deepclone extension's functions for converting value graphs to arrays and back, preserving object identity, references, cycles, and private state—faster and more memory-efficient than serialize/unserialize.

View on GitHub
Deep Wiki
Context7

Symfony Polyfill / DeepClone

This package provides a pure-PHP implementation of the functions and exception classes from the deepclone extension:

  • 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.

License

This library is released under the MIT license.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator