myparcelcom/resource-cleanup
Composer 安装命令:
composer require myparcelcom/resource-cleanup
包简介
Clean up soft-deleted and expired records from your Laravel application after a configurable cutoff date.
README 文档
README
A Laravel package to permanently delete soft-deleted or expired records based on a defined "cleanable" query scope or after a configurable cutoff date.
Requirements
- PHP 8.2+
- Laravel 9, 10, 11, or 12
Installation
composer require myparcelcom/resource-cleanup
Update Laravel's package auto-discovery cache
php artisan package:discover
Publish the config file:
php artisan vendor:publish --tag=resource-cleanup-config
Configuration
config/resource-cleanup.php:
return [ // Records older than this many days will be deleted (default: 90) 'default_retention_days' => env('RESOURCE_CLEANUP_RETENTION_DAYS', 90), // Valid models to clean up 'models' => [ \App\Models\Order::class, \App\Models\AuditLog::class, ], ];
Usage
Artisan Command
Run cleanup for all models defined in the config:
php artisan resource-cleanup:run
Target specific models from the config:
php artisan resource-cleanup:run --model=App\\Models\\Order
Preview what would be deleted without deleting anything:
php artisan resource-cleanup:run --dry-run
Per-Model Cutoff Dates
Implement the CleanableResource contract on any model to define its own retention period:
use Illuminate\Database\Eloquent\Builder; use MyParcelCom\ResourceCleanup\Contracts\CleanableResource; class AuditLog extends Model implements CleanableResource { public static function scopeCleanable(): Builder { // narrow down the query scope by adding where() clauses return self::query(); } }
Testing
With Docker (recommended)
Build the container and run the test suite:
docker compose run --rm app
Run a specific test or filter:
docker compose run --rm app vendor/bin/phpunit --filter test_it_deletes_soft_deleted_records
Drop into a shell inside the container:
docker compose run --rm app bash
Run Composer commands without installing PHP locally:
docker compose run --rm app composer require some/package
Without Docker
composer install
composer test
myparcelcom/resource-cleanup 适用场景与选型建议
myparcelcom/resource-cleanup 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 myparcelcom/resource-cleanup 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 myparcelcom/resource-cleanup 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 39
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-07