Download the PHP package iliaal/lchash without Composer

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

lchash

Tests Version License: PHP-3.01 Follow @iliaa

A small PHP extension that provides a string-keyed hash table backed by klib khash. It has two APIs: four procedural functions for a single per-request table (the original 2005 API), and an LcHash class with $obj[$key] access for any number of per-instance tables.

Supports PHP 7.4 through 8.5, NTS and ZTS, on glibc Linux, musl, macOS, *BSD, and Windows.

lchash first shipped on PECL in 2005. The 1.0.0 release rewrites it for PHP 7.4 and later.

When to use this (and when not to)

Don't use it for speed. PHP arrays are faster on insert and lookup at every size we measured. These numbers come from bench/bench.php on a release build of PHP 8.4 NTS (glibc Linux x86_64, -O2):

N entries Insert (array) Insert (lchash proc) Insert (lchash OO) Lookup (array) Lookup (lchash proc) Lookup (lchash OO) Mem (array) Mem (lchash)
10,000 0.001s 0.001s 0.000s 0.000s 0.001s 0.000s 0.63 MB 0.25 MB
100,000 0.007s 0.014s 0.009s 0.002s 0.009s 0.005s 5.00 MB 2.03 MB
1,000,000 0.111s 0.161s 0.185s 0.052s 0.102s 0.101s 40.0 MB 32.5 MB

To reproduce, run php -d extension=$(pwd)/modules/lchash.so bench/bench.php <N>.

At 1M entries, PHP arrays are 1.4x to 1.7x faster on insert and 2x faster on lookup. PHP's HashTable uses a packed bucket layout with inlined zvals and opcode-level array-access specialization, none of which an extension can use.

lchash uses less memory than PHP arrays at every size: about 40% of the array's memory at 10k entries and about 80% at 1M. Keys and values are refcount-shared zend_strings with no per-entry Bucket overhead.

Reasons to use lchash:

For most code, use a PHP array.

Install

PIE (recommended on PHP 8.x)

PIE is the PHP Foundation's successor to PECL. It installs from Packagist and builds against the active php-config.

Then add extension=lchash to your php.ini.

PECL

The package is still on the PECL channel:

From source

Windows

Every release has pre-built .dll zips for PHP 8.3 / 8.4 / 8.5 × x64 / x86 × NTS / TS. Download the matching zip, extract php_lchash.dll into your ext/ directory, and add extension=lchash to php.ini.

API

Procedural (single per-request table)

Object-oriented (multiple per-instance tables)

Semantics

Both APIs:

Procedural API:

OO API:

Backend

lchash uses one backend on every platform: a vendored copy of klib khash (header-only, MIT-licensed) in khash.h. It has no external dependencies and no build-time probes.

Both APIs hash keys with PHP's DJBX33A (zend_string_hash_val), so collision-DoS exposure is the same as for PHP arrays. klib's open-addressing layout degrades slightly more gracefully than chained buckets under heavy collision.

License

PHP License 3.01 for the extension, MIT for the vendored khash.h (header carries the full notice).


All versions of lchash with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
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 iliaal/lchash contains the following files

Loading the files please wait ...