PHP code example of pinimize / laravel-bz2-compresssion
1. Go to this page and download the library: Download pinimize/laravel-bz2-compresssion library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pinimize / laravel-bz2-compresssion example snippets
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');