Download the PHP package mordilion/huffman-php without Composer

On this page you can find all versions of the php package mordilion/huffman-php. 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 huffman-php

HuffmanPHP

A PHP library for string compression using the Huffman coding algorithm with URL-safe base conversion.

CI PHP

Features

Requirements

Installation

Usage

Basic Encoding

Character-level encoding compresses individual characters based on their frequency. The default output uses Base65 (URL-safe alphabet) when compression is enabled.

Custom Alphabets

Use different character sets to encode compressed output. Smaller alphabets produce longer output but may be more suitable for restricted character sets.

Whole-Word Mode

Treat each input array element as an atomic token instead of breaking it into individual characters. This produces superior compression when the input has repeating words or phrases.

API Reference

Dictionary

__construct(array $values, int $maxLength = 1)

Builds a Huffman dictionary from sample values.

Throws InvalidArgumentException if $maxLength is negative.

getBinary(string $key): ?string

Returns the binary Huffman code for a given key, or null if not found.

getValue(string $binary): string|int|false

Reverse lookup: returns the original key for a binary code, or false if not found.

getMaxLength(): int

Returns the maxLength used during construction.

setValues(array $values): void

Replaces the dictionary mappings. Useful for serializing/deserializing dictionaries.

Huffman

__construct(Dictionary $dictionary, string $compressAlphabet = Huffman::ALPHABET_BASE65)

Creates an encoder/decoder instance.

encode(string $decoded, bool $compress = false): string

Encodes a string using the Huffman dictionary.

Throws RuntimeException if:

decode(string $encoded, bool $compressed = false): string

Decodes a previously encoded string. The $compressed flag must match the $compress flag used during encoding.

Throws RuntimeException if the binary code is not recognized in the dictionary.

Alphabet Constants

Alphabets are used to convert the binary Huffman codes into text. Larger alphabets produce shorter output for the same binary data.

Constant Characters Size
ALPHABET_BASE10 0-9 10
ALPHABET_BASE16 0-9A-F 16
ALPHABET_BASE16_LOWER 0-9a-f 16
ALPHABET_BASE26 A-Z 26
ALPHABET_BASE26_LOWER a-z 26
ALPHABET_BASE36 0-9A-Z 36
ALPHABET_BASE36_LOWER 0-9a-z 36
ALPHABET_BASE62 0-9A-Za-z 62
ALPHABET_BASE65 0-9A-Za-z-_~ 65

Note: Larger alphabets produce shorter output. Base65 is the default and uses only URL-safe characters (digits, letters, hyphen, underscore, tilde).

Error Handling

Testing

License

MIT — see LICENSE for details.


All versions of huffman-php with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
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 mordilion/huffman-php contains the following files

Loading the files please wait ...