Download the PHP package helgesverre/laravel-prunekeeper without Composer

On this page you can find all versions of the php package helgesverre/laravel-prunekeeper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-prunekeeper

Prunekeeper

Archive prunable Eloquent records before deletion.

Tests Latest Version on Packagist Total Downloads License


Laravel's Prunable trait lets you automatically clean up old database records.
But once they're gone, they're gone forever.

Prunekeeper hooks into Laravel's pruning process to export records to CSV or SQL before deletion. Archives are compressed and uploaded to any Laravel filesystem disk (S3, local, etc.), giving you a safety net for compliance, auditing, or "just in case."

When you run php artisan model:prune, Prunekeeper automatically:

  1. Exports matching records to CSV (or SQL)
  2. Compresses the export (ZIP, gzip, bzip2, or tar.gz)
  3. Uploads to your configured storage disk
  4. Allows Laravel to proceed with deletion

Installation

Supports Laravel 11 and 12 on PHP 8.2+, and Laravel 13 on PHP 8.3+. Laravel 11 is past its upstream security support period; package compatibility does not extend framework security support.

Archives contain stored database attributes, including hidden fields. Eloquent accessors, casts, appended attributes, and relationships are not applied. Encrypt and restrict access to archive storage as appropriate for the data being retained.

Partial query projections must include every configured archive column (all table columns by default); otherwise exporting throws before pruning. SQL exports reject NUL-containing strings and stream resources because those values cannot be safely represented as portable SQL string literals. Use CSV for supported binary strings or exclude those columns explicitly. Both formats reject stream resources. SQL archives omit generated columns so the database can recompute them during restoration; explicitly selecting a generated column for SQL fails.

Archiving and pruning run separate queries. Concurrent inserts or updates, or a changing time-based cutoff, can change the matching records between export and deletion. Use a stable cutoff and coordinate writers when exact archive coverage is required. Calling pruneAll() directly bypasses the model:prune event and therefore automatic archiving.

Use unique filenames in custom filename callbacks: an existing storage path causes archiving to fail. The existence check is not an atomic reservation; coordinate concurrent archive runs when using custom names. Uploads use temporary .uploading-* paths; only the final path returned in ArchiveResult represents a completed archive. Callback and event-listener exceptions stop pruning by default, including exceptions after an archive has been uploaded. Keep notification listeners reliable and account for duplicate archives when retrying. fail_silently allows pruning after an archive failure and therefore risks losing unarchived records.

Optionally publish the configuration:

Requirements: PHP 8.2+ with Laravel 11/12, or PHP 8.3+ with Laravel 13, with the ZIP and Intl extensions.

Basic Usage

Add the ArchivePrunedRecords trait to any model that uses Laravel's Prunable or MassPrunable trait:

That's it. When Laravel prunes the model, Prunekeeper archives the records first.

Using with MassPrunable

Works the same way with MassPrunable (bulk deletion without model events):

Configuration

Export Formats

Format Description Best For
CSV (default) Portable, database-agnostic General archiving, analytics, data portability
SQL Database-specific INSERT statements Direct database restoration

SQL exports automatically use the correct identifier quoting for your database:

Compression Drivers

Choose from multiple compression formats:

Driver Extension Requirements
zip (default) .zip ext-zip
gzip .gz ext-zlib
bzip2 .bz2 ext-bz2
targz .tar.gz ext-phar, ext-zlib, phar.readonly=0

Configure in config/prunekeeper.php or via environment:

Artisan Commands

Archive without deleting

Archive records without triggering deletion:

Validate configuration

Validate that column configurations are correct:

Run this in CI/CD to catch configuration errors before deployment.

Customization

Export specific columns

By default, all columns are exported. To limit which columns are archived:

If you specify columns that don't exist, Prunekeeper throws an InvalidColumnException with a helpful message showing available columns.

Exclude sensitive columns globally

Apply column filtering across all models. Configure Prunekeeper in a service provider's boot method:

Custom filename

Override the default filename pattern globally:

Or per-model:

Lifecycle hooks

Hook into the archiving process:

Events

Prunekeeper dispatches Laravel events for integration with queues, notifications, or monitoring:

Event Dispatched When
ArchiveStarting Before archive begins
ArchiveCompleted After successful archive
ArchiveFailed When archive fails
ArchiveSkipped When archive is skipped (disabled, no records, pretend mode)

Disable archiving conditionally

Disable archiving for specific models or environments:

Model discovery

The prunekeeper:archive and prunekeeper:validate commands auto-discover models using the ArchivePrunedRecords trait.

By default, models are discovered in app/Models and app/. Configure custom paths:

Glob patterns are supported:

Pattern Matches
app/Models Standard Laravel location
app/Domain/*/Models app/Domain/Users/Models, app/Domain/Orders/Models, etc.
app/Modules/**/Models Recursively finds all Models directories under app/Modules/

You can also specify models directly via the --model option:

Scheduling

Add pruning to your scheduler in routes/console.php:

Or in Laravel 11+ with bootstrap/app.php:

Preview what will be pruned:

Performance

Prunekeeper handles large datasets efficiently:

For very large tables (millions of records):

Security

When archiving data that may contain sensitive information:

  1. Use column filtering: Implement getArchivableColumns() or use resolveColumnsUsing() to exclude sensitive fields
  2. Use secure storage: Configure your storage disk with appropriate access controls and encryption
  3. Run validation: Use prunekeeper:validate in CI/CD to catch configuration errors

Testing

just dtest runs the complete suite inside Docker with all seven database services. It resolves PHP dependencies inside the container and fails if a required database is unavailable.

Run fresh Laravel 11, 12, and 13 installation and pruning smoke tests in Docker:

This also runs the unit/feature suite and static analysis with matching Testbench dependencies for each Laravel version. Set PRUNEKEEPER_SMOKE_LARAVEL_VERSIONS=13 to test a single version. Only the disposable Laravel 11 test projects permit dependencies blocked by Composer's advisory policy.

Changelog

See CHANGELOG for version history.

Contributing

Contributions are welcome! Please see the repository for guidelines.

Security

If you discover a security vulnerability, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). See LICENSE for details.


All versions of laravel-prunekeeper with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/contracts Version ^11.0|^12.0|^13.0
illuminate/database Version ^11.0|^12.0|^13.0
illuminate/events Version ^11.0|^12.0|^13.0
illuminate/filesystem Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
league/csv Version ^9.6
spatie/laravel-package-tools Version ^1.16
ext-intl Version *
ext-zip Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package helgesverre/laravel-prunekeeper contains the following files

Loading the files please wait ...