loro-dev/loro-php

PHP bindings for Loro CRDT via UniFFI.

Maintainers

Package info

github.com/huanghantao/loro-php

Type:composer-plugin

pkg:composer/loro-dev/loro-php

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.2 2026-06-13 12:34 UTC

This package is auto-updated.

Last update: 2026-07-13 12:45:50 UTC


README

PHP bindings for Loro, built with UniFFI and PHP FFI.

Requirements

  • PHP 8.1+
  • ext-ffi
  • ffi.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