socialdept / atp-orm
Eloquent-like ORM for AT Protocol remote records in Laravel
Requires
- php: ^8.3
- illuminate/support: ^11.0|^12.0|^13.0
- socialdept/atp-cbor: ^0.2
- socialdept/atp-client: ^0.1 || ^0.2 || ^0.3
- socialdept/atp-schema: ^0.4
- socialdept/atp-support: ^0.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.89
- mockery/mockery: ^1.6
- orchestra/testbench: ^9.0|^10.0|^11.0
- phpunit/phpunit: ^11.0|^12.0
- socialdept/atp-signals: ^2.0
Suggests
- socialdept/atp-signals: Enables automatic cache invalidation via firehose/jetstream and CAR-based bulk loading via getRepo (^2.0)
Provides
None
Conflicts
None
Replaces
None
README
Eloquent-like ORM for AT Protocol remote records in Laravel.
This Laravel package reads and writes AT Protocol records in a user's repo through classes that work like Eloquent models. A remote record class names a collection and the atp-schema DTO for it, and then lists, finds, creates, updates and deletes records on the user's PDS, with caching, cursor pagination, dirty tracking, events and backlink queries through Constellation. To learn all about it, head over to the documentation.
Here are a few short examples of what you can do. Generate a remote record class for a collection:
php artisan make:remote-record Post --collection=app.bsky.feed.post
List a user's records, by handle or DID, and page through them:
use App\Remote\Post; $posts = Post::for('alice.bsky.social')->limit(10)->get(); foreach ($posts as $post) { echo $post->text; } $next = $posts->nextPage();
Find one record by its record key or its AT-URI:
$post = Post::for($did)->find($rkey); $post = Post::for($did)->findByUri($uri);
Write as an authenticated account:
$post = Post::as($did)->create([ 'text' => 'Hello from ORM!', 'createdAt' => now()->toIso8601String(), ]); $post->update(['text' => 'Updated text']); $post->delete();
Count and list the records that link to one:
$likes = $post->backlinks()->likes(); $likes->total(); $likes->dids();
It builds on atp-client for reads and writes, on atp-schema for record DTOs, and on atp-support for identity resolution and the Microcosm clients.
Documentation
You'll find the documentation on https://socialde.pt/docs/atp-orm.
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.
