Weave Code
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

Deep Copy Laravel Package

myclabs/deep-copy

DeepCopy creates safe deep clones of PHP objects, recursively copying referenced objects while preserving the original object graph. It handles cyclic references to avoid infinite loops, and supports customization via matchers and filters for specific properties and types.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Feature development: Enables safe duplication of complex object graphs (e.g., CMS content duplication, e-commerce order cloning, or stateful workflow replication) without manual __clone() implementation or circular reference errors
  • Roadmap prioritization: Reduces engineering effort for features requiring object cloning, allowing teams to focus on business logic instead of low-level duplication mechanics
  • Build vs buy decision: Clear buy case – building a reliable deep copy solution handling cycles, Doctrine proxies, and custom filters would require 3-5 developer weeks of error-prone work; this package is battle-tested with 8.8K+ stars and 1.13.4 maturity
  • Use cases: Doctrine entity cloning (with ID reset/collection handling), test data generation (isolating mock objects), audit trail creation (snapshotting complex states), and stateful service duplication

When to Consider This Package

  • Adopt when:
    • You need to clone objects with circular references or complex nested relationships
    • Working with Doctrine ORM (requires specialized filters for proxies/collections)
    • Customizable cloning is needed (e.g., reset IDs, skip specific properties, or transform values during copy)
    • Your team lacks bandwidth to maintain a custom deep-copy implementation
  • Look elsewhere when:
    • Only shallow copies are required (use PHP's native clone keyword)
    • Object structures are trivially simple with no references/cycles
    • Running on unsupported PHP versions (<7.1; though current releases support up to 8.4)
    • The project has zero Composer dependency tolerance (though it's a tiny 100KB dependency)

How to Pitch It (Stakeholders)

"DeepCopy is a battle-tested, zero-configuration solution for safely duplicating complex objects – handling circular references, Doctrine proxies, and custom cloning rules out of the box. It eliminates weeks of engineering effort and risk from building/maintaining custom cloning logic, while ensuring data integrity for critical features like content duplication and audit trails. With 8.8K+ GitHub stars, active maintenance, and MIT licensing, it's the industry-standard choice that accelerates delivery of cloning-dependent features without operational overhead."

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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport