Installation
Debian / Ubuntu
Install from the .deb attached to the latest GitHub release (replace 1.X.X-1 with the current version):
bash
curl -LO https://github.com/AllanGallop/libphp_jsonfast/releases/latest/download/php-jsonfast_1.X.X-1_amd64.deb
sudo apt install ./php-jsonfast_1.X.X-1_amd64.debThe package installs the shared library and drop-in configuration under /etc/php/... so the extension is enabled for CLI and FPM where supported.
TIP
Release artifacts target Linux x86_64 and PHP 8.3. Windows DLL and macOS builds may be added later.
Install manually (prebuilt)
Download the latest Linux build and load it without compiling from source.
- Download and extract:
bash
curl -LO https://github.com/AllanGallop/libphp_jsonfast/releases/latest/download/php_jsonfast-linux-x86_64-php83.zip
unzip php_jsonfast-linux-x86_64-php83.zip- Copy the
.soto your PHP extensions directory:
bash
sudo mkdir -p /usr/local/lib/php/extensions/no-debug-non-zts-20230831
sudo cp php_jsonfast-linux-x86_64-php83.so /usr/local/lib/php/extensions/no-debug-non-zts-20230831/TIP
Adjust the destination directory to match your PHP API version. Run php -i | grep extension_dir to find the correct path.
- Enable in
php.ini:
ini
extension=php_jsonfast-linux-x86_64-php83.soOr reference the full path:
ini
extension=/usr/local/lib/php/extensions/no-debug-non-zts-20230831/php_jsonfast-linux-x86_64-php83.so- Restart PHP-FPM, Apache, or your CLI session if needed.
Load directly for a one-off command:
bash
php -d extension=./php_jsonfast-linux-x86_64-php83.so -r "var_dump(JsonFast::validate('{\"ok\":true}'));"Build from source
Requirements:
- Rust stable toolchain
- PHP 8.x development headers
libclang(for bindgen on Linux/macOS/Windows)
bash
git clone https://github.com/AllanGallop/libphp_jsonfast.git
cd libphp_jsonfast
cargo build --releaseLoad the built extension:
ini
; Linux
extension=/path/to/libphp_jsonfast/target/release/libphp_jsonfast.so
; macOS
extension=/path/to/libphp_jsonfast/target/release/libphp_jsonfast.dylib
; Windows
extension=/path/to/libphp_jsonfast/target/release/php_jsonfast.dllGenerate PHP stubs:
bash
make stubs
# or
cargo php stubs --stdout > php_jsonfast.stub.phpDocker
Build and open a shell in the project container:
bash
docker compose build
docker compose run --rm php-rust bashInside the container:
bash
make test
make benchmarkVerify
bash
php -m | grep jsonfast
php -r "var_dump(class_exists('JsonFast'));"