Code Monkey home page Code Monkey logo

compress's Introduction

๐Ÿ”จ compress

Compress is a really minimal tool --in fact a wrapper for some chained low level functions-- that can compress any arbitrary piece of data (text, arrays, objects, etc.)


Work in Progress (WIP) โ€” Do not use in production yet:

  • It has not undergone extensive testing.
  • Primarily intended for internal projects, subject to potential breaking changes without prior notice.
  • There are likely many missing features.

  • ๐ŸŽ‰ The compressed result is URL safe
  • The gmp extension is required in order to work

Example usage

<?php
declare(strict_types=1);

use Kristos80\Compress\Compress;

require_once __DIR__ . "/../vendor/autoload.php";

# A not so useful example, but you get the idea that anything can be compressed as internally it gets serialized
$data = ["foo" => "dummy"];
# Prints wHFQO5fHxiiWjq7Pnd5dWK6yLNiIPGxWslAOBQMob81XgHJouEzr3zlNEN2RDQv2
echo $compressedData = Compress::compress($data);
# Dumps the `$data` array
print_r(Compress::decompress($compressedData));

# A more useful example
$longString = str_repeat("This is a very long string that actually is better to compress it to make it smaller", 100);
# Prints 3ds5WnDJjriKizqth86Zc9MBNQ3tQbzj7mwrqHNeMYZdPZBfIgqTQMkGzgr5dHNKmmkXlJhCM8fPYO5nxUbzNsdyGEipyNwSvVVRv2eEpmCjEVHcVzCk6yonW5BFf48ZXFhvNHPDJVp2PAo6EvP8PVXu3YpcmHrt22vByhgjP2msTPreXjmIu45Cswj3ICjt8U4
# Instead of the 8400 characters of the original string
echo Compress::compress($longString);

compress's People

Contributors

andreasgeorgantzelis avatar kristos80 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.