Download the PHP package google/crc32 without Composer
On this page you can find all versions of the php package google/crc32. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package crc32
Short Description Various CRC32 implementations
License Apache-2.0
Homepage https://github.com/google/php-crc32
Informations about the package crc32
php-crc32
Deprecated: Since PHP 8.0, the crc32 algorithms within PHP are using hardware accelerated instructions, and are surprisingly fast. Thus this extension is not needed anymore!
CRC32 implementations, that support all crc32 polynomials, as well as (if you install the pecl extension) hardware accelerated versions of CRC32C (Castagnoli).
Supports PHP 7.4 though PHP 8.2. Older PHP versions are supported with "v0.1.0".
Usage
Depending on the environment and the polynomial, CRC32::create
will choose
the fastest available version, and return one of the following classes:
Google\CRC32\PHP
- A pure PHP implementation.Google\CRC32\Builtin
- A PHP Hash framework implementation.Google\CRC32\Google
- A hardware accelerated implementation (using google/crc32c).
When reading 1M byte chunks, using CRC32::CASTAGNOLI
with PHP 7.4 on a 2014 Macbook Pro we get the following performance (higher is better):
Install
crc32c.so
To use the hardware accelerated, a custom PHP extension must be installed. This makes use of google/crc32c which provides a highly optomised CRC32C
(Castagnoli) implementation using the SSE 4.2 instruction set of Intel CPUs.
The extension can be installed from pecl, or compiled from stratch.
Once installed or compiled, you'll need to add extension=crc32c.so
to your php.ini file.
Compile (Linux / Mac)
Ensure that composer, build tools (e.g build-essential, cmake, etc), and php dev headers (e.g php-dev) are installed.
Simple (using Makefile):
Alternatively (manually):
The extension will now be at ext/modules/crc32c.so
. This file should be copied to your extension directory and reference in your php.ini.
Testing
make test
will test with the current PHP. make test_all
will search for available
PHP installs, and test with all of them.
Benchmark
To compare the performance of the different CRC32C
implementations, run make benchmark
.
Related
TODO
- [ ] Test if this works on 32 bit machine.
- [x] Add php unit (or similar) testing.
- [x] Publish to packagist
- [ ] Publish to pecl (https://pecl.php.net/account-request.php)
- [x] Update instructions for linux.
Licence (Apache 2)
This is not an official Google product (experimental or otherwise), it is just code that happens to be owned by Google.