lazev/phplogpacker
最新稳定版本:v1.0.0
Composer 安装命令:
composer create-project lazev/phplogpacker
包简介
A PHP tool for log packing and rotation
README 文档
README
A lightweight PHP utility to automatically compress and archive files when they reach a defined size threshold.
✨ Features
- ✅ Compresses files >50MB (default) using 7Zip or fallback to Zip
- ✅ Recursive directory scanning (includes subfolders)
- ✅ Configurable retention policy and compression settings
- ✅ Zero dependencies – pure PHP CLI tool
🚀 Usage
Basic Command
php logpacker.php /target/directory/
How It Works
- Scans
/target/directory/and all subfolders - Compresses files exceeding
max_file_size_MB(default: 50MB) - Maintains
num_files_archivedversions (default: 5) - Oldest archives are automatically deleted
⚙️ Configuration (optional)
To customize, create a logpacker.ini file in the script's root directory:
; logpacker.ini num_files_archived = 5 ; Number of archived versions to keep max_file_size_MB = 50 ; Minimum file size to trigger compression (in MB) days_last_change = 0 ; [TODO] Archive files modified X days ago days_from_creation = 0 ; [TODO] Archive files created X days ago archive_extension = 7z ; Compression format (7z or zip)
🔄 Archive Rotation Example
Original structure:
error.log (60MB)
After first run:
error.log.1.7z (compressed)
After subsequent runs:
error.log.1.7z → error.log.2.7z
error.log.2.7z → error.log.3.7z
...
error.log.5.7z → deleted (oldest archive)
📦 Compression Methods
- 7Zip (default, if installed on system)
- Zip (fallback if 7Zip unavailable)
📜 License
Open-source under the MIT License.
统计信息
- 总下载量: 17
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-17