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.

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

Optionally publish the configuration:

Requirements: PHP 8.2+ and Laravel 11 or 12.

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

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
illuminate/database Version ^11.0|^12.0
illuminate/events Version ^11.0|^12.0
illuminate/filesystem Version ^11.0|^12.0
illuminate/support Version ^11.0|^12.0
league/csv Version ^9.6
spatie/laravel-package-tools Version ^1.16
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 ...