pinimize/laravel-bz2-compresssion
最新稳定版本:v0.1.0
Composer 安装命令:
composer require pinimize/laravel-bz2-compresssion
包简介
A Laravel package for compression with Bzip2.
README 文档
README
This package provides Bzip2 compression support for the Pinimize compression and archive package for Laravel.
Requirements
- PHP 8.2 or higher
- Laravel 11 or higher
- The
ext-bz2PHP extension must be installed and enabled
Installation
First, ensure that the Bzip2 PHP extension is installed. You can check this by running:
php -m | grep bz2
If you don't see 'bz2' in the output, you'll need to install the extension before proceeding.
Once the Bzip2 extension is installed, you can install the package via composer:
composer require pinimize/laravel-bz2-compresssion
Prerequisites
This package is an extension of the Pinimize Compression and Archive package. The main Pinimize package will be automatically installed as a dependency for this package.
Configuration
After installation, you need to add the Bzip2 driver configuration to your config/pinimize.php file. If you haven't published th main config file, you can do so by running this command:
php artisan vendor:publish --provider="Pinimize\PinimizeServiceProvider" --tag="config"
Add the following to the drivers array:
'bz2' => [ 'disk' => env('COMPRESSION_DISK', null), ],
Your complete compression configuration should look something like this:
'compression' => [ 'default' => env('COMPRESSION_DRIVER', 'gzip'), 'mixin' => env('COMPRESSION_REGISTER_MIXIN', true), 'drivers' => [ ... // Other drivers 'bz2' => [ 'disk' => env('COMPRESSION_DISK', null), ], ], ],
Usage
Once configured, you can use the Bzip2 driver just like any other compression driver in Pinimize. All methods available in the main Pinimize package are fully supported with the Bzip2 driver. For example:
use Illuminate\Support\Str; use Illuminate\Support\Facades\Storage; use Pinimize\Facades\Compression; use Pinimize\Facades\Decompression; // When you have made bz2 the default driver in your configuration: $compressedStringZlib = Str::compress($originalString); $decompressedStringGzip = Str::decompress($compressedStringGzip); // By specifying the driver: $compressedStringZlib = Str::compress($originalString, 'bz2'); $decompressedStringGzip = Str::decompress($compressedStringGzip, 'bz2'); // Or with the Storage facade: Storage::compress('/path/to/original.json', '/path/to/compressed.json.bz2'); Storage::decompress('/path/to/compressed.json.bz2', '/path/to/decompressed.json'); // Compress a string using Bzip2 $compressed = Compression::driver('bz2')->string('Hello, World!'); // Default driver $compressed = Compression::string('Hello, World!'); Compression::put('path/to/compressed.csv.bz2', '/path/to/original.csv');
For more detailed usage instructions and a full list of available methods, please refer to the Pinimize Compression and Archive documentation.
Important Notes
- The Bzip2 compression algorithm does not support compression levels. The
levelparameter in the configuration is ignored for the Bzip2 driver. - The Bzip2 extension must be installed on your server for this package to work. If you're using a managed hosting service, you may need to contact your hosting provider to have it installed.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Testing
Run the tests with:
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.
pinimize/laravel-bz2-compresssion 适用场景与选型建议
pinimize/laravel-bz2-compresssion 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 35 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 09 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「compression」 「laravel」 「bz2」 「bzip2」 「pinimize」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 pinimize/laravel-bz2-compresssion 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pinimize/laravel-bz2-compresssion 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 pinimize/laravel-bz2-compresssion 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Smart compressed files extractor
Asset Management for PHP
Image optimization / compression library. This library is able to optimize png, jpg and gif files in very easy and handy way. It uses optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim and jpegtran tools.
Provides line-by-line readers and iterators for Wikibase/Wikidata JSON dumps
Yii2 integration for TinyPng
Smart compressed files extractor
统计信息
- 总下载量: 35
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-09-04