Search by

packvium / native-bridge

Optional FFI backend for Packvium with pure-PHP fallback

Maintainers

Package info

github.com/toxakara/packvium-php-bridge

Homepage

pkg:composer/packvium/native-bridge

Transparency log

Statistics

Installs: 4

Dependents: 0

Suggesters: 1

Stars: 0

Open Issues: 0

v1.0.0 2026-09-01 15:10 UTC

This package is auto-updated.

Last update: 2026-09-01 15:12:16 UTC


README

Optional native backend for Packvium. It uses a Rust shared library through PHP FFI when one is available, and otherwise uses the pure-PHP Packvium package.

Full documentation, the constraint reference and benchmarks live at packvium.com.

Install

composer require packvium/native-bridge packvium/packvium

PHP 7.4 or later is required. Enable ext-ffi and provide a compatible shared library only when you want the native backend; neither is required for the PHP fallback.

Quick start

<?php

use Packvium\Native\NativePacker;

$packer = new NativePacker('/opt/packvium/libpackvium_ffi.so');
$result = $packer->pack($request);

echo $packer->backend(), PHP_EOL; // "rust" or "php"
echo $result['status'], PHP_EOL;

Pass the same request format used by packvium/packvium. If the extension, library or health check is unavailable, NativePacker selects the PHP backend instead of failing the packing request.

Omit the library path (or pass null) to always use the pure-PHP backend — useful in a test suite or on a host that never provisions the shared library:

$packer = new NativePacker();   // no library path: pure PHP, deterministic either way
echo $packer->backend(), PHP_EOL; // "php"

Examples

Runnable, in examples/. Each one is a single file you can read top to bottom and execute without a project around it.

File What it shows
basic.php Pack through the bridge and report which backend answered.
php examples/basic.php                            # pure PHP
php examples/basic.php /path/to/libpackvium.so    # compiled engine

Running it both ways is the point: the same request must come back with the same answer whichever backend served it.

When to use it

Use this package when your deployment already manages the shared library and you want the native engine. For a zero-configuration installation, use packvium/packvium directly.

The Packvium family

One request and result contract, implemented independently in four engines (Rust, Python, PHP, JavaScript) and held to identical placements on a shared fixture set. Pick the package for your stack; mixing them in one system is safe.

Documentation, the constraint reference and the benchmarks are at packvium.com.

Package Install Source
Python — packvium pip install packvium packvium-python
PHP — packvium/packvium composer require packvium/packvium packvium-php
Rust — packvium packvium = "1.0" packvium-rust
Node.js — @packvium/engine npm install @packvium/engine packvium-node
Browser / WebAssembly — @packvium/browser npm install @packvium/browser packvium-wasm
PHP FFI bridge — packvium/native-bridge composer require packvium/native-bridge packvium-php-bridge
Python native selector — packvium-native from source until the native wheels ship packvium-python-adapter

License

MIT. See LICENSE.