loro-dev / loro-php
PHP bindings for Loro CRDT via UniFFI.
v0.1.2
2026-06-13 12:34 UTC
Requires
- php: >=8.1
- composer-plugin-api: ^2.2
- ext-ffi: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3
- phpunit/phpunit: ^10.5
README
PHP bindings for Loro, built with UniFFI and PHP FFI.
Requirements
- PHP 8.1+
ext-ffiffi.enable=1
Install
composer require huanghantao/loro-php
Composer will ask whether huanghantao/loro-php may run as a plugin. Allow it
to download the native library for your platform.
For CI:
composer config allow-plugins.huanghantao/loro-php true
composer require huanghantao/loro-php
To use your own native library instead:
export LORO_PHP_LIBRARY=/absolute/path/to/libloro_php.dylib
Usage
<?php require __DIR__ . '/vendor/autoload.php'; use Loro\LoroDoc; $doc = new LoroDoc(); $text = $doc->getText('text'); $text->insert(0, 'Hello, Loro'); $doc->commit(); echo $text->slice(0, $text->lenUnicode());
Run PHP with FFI enabled:
php -d ffi.enable=1 example.php
Development
composer install ./scripts/build_php_ffi.sh LORO_PHP_LIBRARY="$(pwd)/rust/target/release/libloro_php.dylib" composer test composer cs-fix