Download the PHP package pinimize/laravel-compression-and-archive without Composer

On this page you can find all versions of the php package pinimize/laravel-compression-and-archive. 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-compression-and-archive

Pinimize

Latest Version on Packagist Total Downloads Tests License

Pinimize is a powerful Laravel package that simplifies file compression and decompression. It provides a clean and intuitive API for handling various compression and decompression tasks in your Laravel applications, with full support for Laravel's Storage system.

Archiving and unarchiving operations are in coming very soon.

Paused

Development on this project is currently paused because of the lack of time to maintain it.

Features

Table of Contents

Installation

You can install the package via composer:

Configuration

Publish the configuration file:

The config/pinimize.php file allows you to configure the compression and decompression settings for the Pinimize package. This file is created when you publish the package configuration.

Default Driver

You can set the default compression driver using the COMPRESSION_DRIVER environment variable or by directly modifying the compression.default value in the config file. The default is set to 'gzip'.

Compression Drivers

The package supports two compression drivers: 'gzip' and 'zlib'. Each driver has its own configuration options:

Gzip Driver

Zlib Driver

More drivers will be added in future releases. They are kept separate to avoid requiring you to install php extensions you might not need and to keep the codebase clean.

Compression Levels

For both drivers, you can set the compression level:

Storage Disk

The disk option allows you to specify which disk to use for file operations. This integrates with Laravel's Storage system:

To set the disk, use the COMPRESSION_DISK environment variable or modify the disk value directly in the config file.

Environment Variables

For easy configuration, you can use the following environment variables:

Remember to update your .env file with these variables as needed.

Basic Usage

String Macros

The Pinimize package extends Laravel's Str facade with two convenient macros for string compression and decompression:

These macros allow you to easily compress & decompress data using the default compression driver.

To decompress compressed data:

These macros provide a simple and convenient way to compress and decompress strings in your Laravel application, leveraging the power of the Pinimize package.

Storage Macros

The Pinimize package extends Laravel's Storage facade with two convenient methods for file compression and decompression:

Compression:

Parameters:

Return Value:

Decompression:

Parameters:

Return Value:

Examples:

These methods provide a simple and convenient way to compress and decompress files in your Laravel application's storage system, leveraging the power of the Pinimize package.

Compressing Strings

To compress data to a string, you can use the string method. Take a look at the Supported Data Types for this method. This method is useful for compressing small amounts of data in memory.

The Decompression facade works in a similar way, only it decompresses the data:

Compressing Resources

You can compress data and have the compressed content returned as a resource by using the resource method. This method useful for working with data without loading everything into memory.

Take a look at the Supported Data Types for this method.

The Decompression facade works in a similar way, only it decompresses the resource:

Compressing Files

The put method is a versatile way to write compressed content to a file. It supports various input types and offers flexibility in where the compressed file is stored.

The Decompression facade works in a similar way, only it decompresses the resource:

Using Storage Disks

By default, the put method will use the filesystem provided in then config file, which defaults to the local filesystem. However, you can use Laravel's Storage facade to write compressed files to any configured disk by specifying the disk option:

This will compress the content and store it on the S3 disk (assuming you have configured an S3 disk in your filesystems.php configuration).

You can use any disk configured in your config/filesystems.php:

When using the disk option, the Compression service will utilize Laravel's Storage facade to handle file operations, allowing you to take advantage of all the benefits of Laravel's filesystem abstraction.

Note that when using storage disks, the path you provide as the first argument to put will be relative to the disk's configured root directory.

Supported Data Types

The string, resource and put methods can handle several types of input:

  1. Strings:

If the provided string is a path to a file, the package will first attempt to locate the file on the specified filesystem. If the file cannot be found, the package will treat the string as raw content to be compressed.

This behavior allows flexibility in handling both file paths and direct content compression within the same interface. If you want to be certain that a file specified by a path should be loaded, consider using the Illuminate\Http\File object or passing it in as a resource.

  1. PSR-7 StreamInterface:

  2. Laravel's File object:

  3. Laravel's UploadedFile object:

  4. PHP resource:

Advanced Usage

Downloading Compressed Files

To create a download response for a compressed file:

This also works for decompressing files:

Compression Ratio

To get the compression ratio between original and compressed data:

Supported Algorithms

To get a list of supported compression algorithms for the current driver:

Drivers

Gzip Driver

The Gzip driver uses the gzencode function for compression. It supports the FORCE_GZIP encoding and produces files with a .gz extension.

Zlib Driver

The Zlib driver uses the zlib_encode function for compression. It supports ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, and ZLIB_ENCODING_DEFLATE encodings. Files compressed with this driver have a .zz extension.

Custom Drivers

You can create custom compression drivers by extending the CompressionContract interface and implementing the required methods. Then, register your custom driver in a service provider:

After registering your custom driver, you can use it like any other compression driver in your application. The same process applies for creating custom decompression drivers.

Links

Testing

Run the tests with:

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.


All versions of laravel-compression-and-archive with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/contracts Version ^11.0|^12.0
maennchen/zipstream-php Version ^3.1
nelexa/zip Version ^4.0
ext-fileinfo Version *
ext-zip Version *
ext-zlib 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 pinimize/laravel-compression-and-archive contains the following files

Loading the files please wait ....