定制 loro-dev/loro-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

loro-dev/loro-php

Composer 安装命令:

composer require loro-dev/loro-php

包简介

PHP bindings for Loro CRDT via UniFFI.

README 文档

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

Release

Tag a release and push it. The GitHub workflow builds native libraries and uploads loro-php-native-<platform>.tar.gz plus checksum files.

git tag -a v0.1.0 -m "Release v0.1.0"
git push origin v0.1.0

Set LORO_PHP_SKIP_NATIVE_INSTALL=1 to skip native download, or LORO_PHP_NATIVE_RELEASE=<tag> to force a native artifact tag.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-13