Search by

socialdept / atp-cbor

socialdept

CBOR, CAR, and CID binary encoding for AT Protocol in PHP

Package info

github.com/socialdept/atp-cbor

pkg:composer/socialdept/atp-cbor

Statistics

Installs: 1 664

Dependents: 5

Suggesters: 1

Stars: 0

Open Issues: 0

v0.2.3 2026-10-21 09:57 UTC

This package is auto-updated.

Last update: 2026-11-07 08:21:12 UTC


README

CBOR Header

CBOR, CAR, and CID binary encoding for AT Protocol in PHP.


This package reads and writes the binary formats of the AT Protocol in plain PHP, with no Laravel dependency. It decodes and encodes DAG-CBOR, reads CAR archives and the records in a repository's tree, parses CIDs, checks getRecord proofs, and signs PLC operations with secp256k1 keys. To learn all about it, head over to the documentation.

Here are a few short examples of what you can do. Decode CBOR from a firehose event:

use SocialDept\AtpCbor\Core\CBOR;

$decoded = CBOR::decode($binaryData);

Read the blocks of a CAR archive into a map of CID to bytes:

use SocialDept\AtpCbor\Core\CAR;

$blocks = CAR::blockMap($carData);

Parse a CID and turn it back into a string:

use SocialDept\AtpCbor\Core\CID;

$cid = CID::fromString('bafyreie5cvv4h45feadgeuwhbcutmh6t7ceseocckahdoe6uat64zmz454');
$cid->version;    // 1
$cid->toString();

Check that a record from com.atproto.sync.getRecord sits where its repo's commit says:

use SocialDept\AtpCbor\Proof\RecordProof;

$proven = RecordProof::verify($car, 'app.bsky.graph.verification', $rkey, did: $issuerDid);
$proven->record;

Documentation

You'll find the documentation on https://socialde.pt/docs/atp-cbor.

Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving it? Feel free to create an issue on GitHub.

Testing

vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see LICENSE for more information.