socialdept / atp-signals
Build Reactive Signals for Bluesky's AT Protocol Firehose in Laravel
Requires
- php: ^8.3
- illuminate/console: ^11.0|^12.0|^13.0
- illuminate/database: ^11.0|^12.0|^13.0
- illuminate/http: ^11.0|^12.0|^13.0
- illuminate/routing: ^11.0|^12.0|^13.0
- illuminate/support: ^11.0|^12.0|^13.0
- ratchet/pawl: ^0.4
- react/event-loop: ^1.5
- socialdept/atp-cbor: ^0.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.89
- orchestra/testbench: ^9.0|^10.0|^11.0
- phpunit/phpunit: ^11.0|^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Consume real-time AT Protocol events in your Laravel application.
This package lets a Laravel application react to AT Protocol events as they happen. A Signal is a class that names the events it wants, by event type, collection, operation or DID, and handles each one, in the consumer process or on a queue. Events come from Jetstream, the firehose or an Obelisk archive, and the cursor is saved so a restarted consumer resumes where it stopped. For code that keeps its own cursor, Jetstream v2 and labeler streams deliver events and labels in batches. To learn all about it, head over to the documentation.
Here are a few short examples of what you can do. Write a Signal that handles every new post:
use SocialDept\AtpSignals\Events\SignalEvent; use SocialDept\AtpSignals\Signals\Signal; class NewPostSignal extends Signal { public function eventTypes(): array { return ['commit']; } public function collections(): ?array { return ['app.bsky.feed.post']; } public function handle(SignalEvent $event): void { logger()->info('New post', [ 'did' => $event->did, 'text' => $event->getRecord()->text ?? null, ]); } }
Match several collections with a wildcard, and only the operations you care about:
use SocialDept\AtpSignals\Enums\SignalCommitOperation; public function collections(): ?array { return ['app.bsky.feed.*', 'app.bsky.graph.*']; } public function operations(): ?array { return [SignalCommitOperation::Create]; }
Handle events on a queue instead of in the consumer:
public function shouldQueue(): bool { return true; }
Then start consuming:
php artisan signal:consume
Documentation
You'll find the documentation on https://socialde.pt/docs/atp-signals.
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.
