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

Doctrine Soft Delete Laravel Package

chrisbaltazar/doctrine-soft-delete

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Compliance & Data Retention: Enables GDPR/CCPA-compliant "soft delete" operations without permanent data loss, preserving audit trails while respecting user privacy requests. Aligns with legal requirements for data erasure while maintaining business continuity (e.g., analytics, reporting).
  • Architectural Consistency: Standardizes soft-delete behavior across the codebase, reducing ad-hoc implementations (e.g., manual WHERE deleted_at IS NULL clauses) and technical debt. Supports a single source of truth for data lifecycle management.
  • Build vs. Buy Decision: Avoids reinventing soft-delete logic (e.g., custom Doctrine filters, migration scripts) and leverages a battle-tested Symfony/Doctrine solution with minimal overhead. Justifies investment in a maintainable, scalable approach.
  • Use Cases:
    • User Management: Temporary deactivations (e.g., suspended accounts) without breaking user analytics or segmentation.
    • E-Commerce: Seasonal product "deletion" with restore capability (e.g., holiday items).
    • Audit & Compliance: Preserve historical data for investigations while hiding it from active queries.
    • Multi-Tenant SaaS: Soft-delete tenant data without cascading hard deletes, enabling data isolation.
    • Legacy System Modernization: Gradually introduce soft deletes to older systems without full rewrites.
  • Roadmap Enabler: Paves the way for future features like:
    • Time-based retention policies (e.g., auto-purge records older than X days).
    • Role-based visibility (e.g., admins see soft-deleted records, users don’t).
    • Integration with backup systems (e.g., auto-archive soft-deleted data).

When to Consider This Package

  • Adopt if:

    • Your primary stack is Symfony 6.4+ with Doctrine ORM (core architecture).
    • You need transparent soft deletes without manual query filtering (e.g., WHERE deleted_at IS NULL).
    • Your database is MySQL 5.7+ (for generated columns and auto_generated_active_flag).
    • You want to avoid unique index conflicts during soft deletes (via auto-generated flags).
    • Your team prioritizes developer productivity (zero-config, autowiring, PHP 8 attributes).
    • You’re building a long-term product where data retention policies may evolve (e.g., compliance, analytics).
    • You’re migrating from hard deletes to a more flexible approach with minimal disruption.
  • Look elsewhere if:

    • You’re not using Symfony/Doctrine (e.g., Laravel, raw SQL, or another ORM like Eloquent).
    • Your database is PostgreSQL/SQLite (generated columns may not apply; use deleted_at column only).
    • You need hard deletes (this package is soft-delete only; consider Doctrine lifecycle callbacks).
    • Your app has strict performance constraints (Doctrine filters add minor overhead; benchmark if critical).
    • You’re using Doctrine < 3.6 or Symfony < 6.4 (compatibility issues).
    • Your team lacks PHP/Symfony expertise (requires understanding Doctrine filters, migrations, and attributes).
    • You need multi-database support (e.g., MySQL + PostgreSQL) without custom logic.
    • Your use case is simple (e.g., a single table with occasional soft deletes); Laravel’s SoftDeletes trait may suffice.

How to Pitch It (Stakeholders)

For Executives:

*"This package lets us handle data privacy requests (like GDPR’s ‘right to erasure’) without losing critical data—think of it as a ‘pause’ button for records. Users get compliance, we keep our analytics and history intact, and developers avoid reinventing the wheel. It’s a turnkey solution that:

  • Saves time: No manual query tweaks or custom scripts.
  • Reduces risk: Prevents accidental data loss while meeting legal requirements.
  • Scales: Works seamlessly as our product grows (e.g., multi-tenancy, complex retention policies). The cost? Minimal—a Composer install and a few lines of config. The ROI? Faster development, fewer compliance headaches, and happier customers who trust we’re protecting their data responsibly."*

For Engineering:

*"This bundle automates soft deletes in Doctrine, so we never have to manually filter deleted_at columns. Key advantages:

  • Transparency: All queries automatically exclude soft-deleted records via a Doctrine filter—no forgotten WHERE clauses.
  • Safety: Uses MySQL generated columns to avoid unique index conflicts during soft deletes (e.g., duplicate emails).
  • Zero Boilerplate: Works with Symfony’s autowiring—just implement SoftDeletableInterface and add a deletedAt field.
  • Future-Proof: Aligns with modern Doctrine/Symfony (PHP 8.1+, Symfony 6.4+) and supports advanced features like #[SoftDeleteUniqueIndex].

Tradeoffs:

  • Adds a tiny query overhead (negligible for most apps; benchmark if critical).
  • Requires MySQL 5.7+ (generated columns).
  • Symfony-centric: Not a drop-in for Laravel/Eloquent (would need custom integration).

Recommendation: Adopt for new projects or Symfony-powered modules. For existing Laravel apps, evaluate whether the effort to bridge Doctrine/Eloquent justifies the benefits—or stick with SoftDeletes trait for simplicity."*

For Data/Compliance Teams:

*"This solution ensures we can honor data deletion requests without permanently losing records—critical for:

  • GDPR/CCPA compliance: ‘Right to erasure’ without breaking audit trails.
  • Internal investigations: Preserve historical data for fraud or legal cases.
  • Analytics integrity: Soft-deleted records don’t skew metrics or reports.

The package’s auto-generated flags also prevent data corruption (e.g., duplicate emails) during soft deletes, which is a common pain point in manual implementations. It’s a low-risk, high-reward way to future-proof our data lifecycle management."*

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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity