PHPackages                             macula-io/macula-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. macula-io/macula-php-sdk

ActiveLibrary

macula-io/macula-php-sdk
========================

PHP client for the Macula mesh wire protocol -- a thin FFI binding over macula-go-sdk's compiled C ABI (unary RPC, PubSub, content transfer, streaming RPC, both caller and provider roles)

v0.1.0(today)02↑2900%Apache-2.0PHPPHP &gt;=8.1CI passing

Since Aug 28Pushed todayCompare

[ Source](https://github.com/macula-io/macula-php-sdk)[ Packagist](https://packagist.org/packages/macula-io/macula-php-sdk)[ Docs](https://github.com/macula-io/macula-php-sdk)[ RSS](/packages/macula-io-macula-php-sdk/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (1)Versions (2)Used By (0)

macula-php-sdk
==============

[](#macula-php-sdk)

[![CI](https://camo.githubusercontent.com/d55fcd08ffd319219bcc0ee4b0c2be3f2557454151d7022fc889d17c8019e452/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d6163756c612d696f2f6d6163756c612d7068702d73646b2f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d4349)](https://github.com/macula-io/macula-php-sdk/actions/workflows/ci.yml)[![License](https://camo.githubusercontent.com/7426fe13d83dcb302246d44422970a90946abc806e4e9b27352acab3c2a42f8e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4170616368652d2d322e302532304f522532304d49542d626c75652e737667)](#license)[![PHP](https://camo.githubusercontent.com/b4de2706a103497f76bc4a0222f46bb57cf6c887d04067d78e74446e98abe6e7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e312532422d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://php.net)[![Go](https://camo.githubusercontent.com/6b4ff39b898a48e8b1c1c987f5e5c19e1b4ec96af210ecafa1179b2720162c60/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f676f2d312e32352532422d3030414444383f6c6f676f3d676f)](https://go.dev)[![Buy Me A Coffee](https://camo.githubusercontent.com/919b059008362d2939cf1455a6cc0ad654e1cc6a7a6fedbf1b605beaa9e2e839/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4275792532304d6525323041253230436f666665652d737570706f72742d79656c6c6f772e737667)](https://buymeacoffee.com/rlefever)

   ![Macula](assets/macula-php-full-light.svg)

 **PHP client for the Macula SDK wire protocol**

---

**Status, 2026-08-28 — feature-complete, live-verified end to end**(PHP → `ext-ffi` → Go C ABI → QUIC → a real production station), matching [`macula-go-sdk`](https://github.com/macula-io/macula-go-sdk) and [`macula-rust-sdk`](https://github.com/macula-io/macula-rust-sdk): handshake, unary RPC, PubSub, content transfer, and streaming RPC, every primitive in both caller and provider roles.

A PHP client for the [Macula](https://github.com/macula-io/macula) wire protocol. Architecturally this is a thin binding, not a third from-scratch protocol port: `macula-go-sdk` already has a complete, live-verified implementation of the wire protocol with a plain blocking API (no goroutines/channels required of the caller) — a close match for PHP's own default blocking-call execution model. This repo wraps that existing SDK as a C shared library and loads it from PHP via `ext-ffi`, rather than re-implementing CBOR/QUIC/Ed25519/frame signing a third time.

Rust's own mobile bindings (`macula-rust-sdk-ffi`) took the analogous approach for Kotlin/Swift via UniFFI — no UniFFI backend exists for PHP, so this repo hand-builds a much simpler *synchronous* C ABI directly (PHP calls a blocking C function; the Go side blocks on the QUIC operation internally and returns), skipping the async-callback plumbing UniFFI needs for Kotlin coroutines / Swift `async` entirely — with one exception: unary-RPC provider dispatch needs a real rendezvous (a PHP handler runs *between* "a CALL arrived" and "send the reply"), which this repo builds as a goroutine + channel pair on the Go side, split into two PHP-facing calls (`Session::serveWaitForCall()` returning a `PendingCall`, then `PendingCall::replyResult()`/`replyError()`) — see [Provider dispatch](#provider-dispatch-unary-rpc) below.

New to Go? You'll never write any
---------------------------------

[](#new-to-go-youll-never-write-any)

This SDK is PHP. The only thing Go is used for is compiling one shared library (`libmacula.so`) that PHP loads at runtime — you run one build command and never touch Go again. If you don't have Go installed:

- **Any OS**: download the installer from [go.dev/dl](https://go.dev/dl/) and follow its instructions, or
- **macOS**: `brew install go`
- **Debian/Ubuntu**: `sudo apt install golang-go` (check the version is ≥ 1.25 — if your distro's package is older, use the go.dev installer instead)
- **Arch**: `sudo pacman -S go`
- **Fedora**: `sudo dnf install golang`

Verify with `go version`, then follow [Quick start](#quick-start) below — `cd cabi && go build ...` is the one and only Go command you'll ever run. A future release may ship prebuilt `libmacula.so` binaries via Composer so this step isn't needed at all; for now, building it yourself is a single command that takes a few seconds.

Features
--------

[](#features)

PrimitiveCallerProviderNotesHandshake (CONNECT/HELLO)✅—Unary RPC (CALL/RESULT/ERROR)✅✅Provider via a goroutine+channel rendezvous, see belowPubSub (PUBLISH/SUBSCRIBE/EVENT)✅✅A subscriber gets its own publish, verified liveContent transfer (single-block + chunked)✅✅Content-addressed, BLAKE3/SHA-256, Merkle-verifiedStreaming RPC (STREAM\_OPEN/DATA/END/REPLY)✅✅Provider via `streamAccept()` — no rendezvous needed, unlike unary RPCRPC advertise/unadvertise✅—Structure
---------

[](#structure)

```
cabi/           Go module, builds libmacula.so via `go build -buildmode=c-shared`.
                Plain consumer of macula-go-sdk's public API -- no changes
                needed to macula-go-sdk itself. You never edit this unless
                you're adding a new wire primitive.
cabi/testc/     A standalone C smoke test, independent of PHP -- proves the
                cgo boundary and a real handshake work without needing PHP
                installed at all.
src/            PHP composer package -- this is what you actually use.
                Binding.php loads libmacula.so via FFI::cdef(); KeyPair,
                Session, Value, CallResponse, Event, StreamHandle/
                StreamItem/StreamReply/StreamOpenInfo, PendingCall are
                the public API.
examples/       One runnable script per wire primitive, against the real
                production fleet -- see Examples below.
tests/          Offline PHPUnit suite -- no network, no live station.
                See Testing below.

```

Quick start
-----------

[](#quick-start)

```
cd cabi && go build -buildmode=c-shared -o libmacula.so . && cd ..
composer install
php examples/01_handshake.php
```

```
