Build Reactive Signals for Bluesky's AT Protocol Firehose in Laravel
1[](https://github.com/socialdept/atp-signals)
2
3<h3 align="center">
4 Consume real-time AT Protocol events in your Laravel application.
5</h3>
6
7<p align="center">
8 <br>
9 <a href="https://packagist.org/packages/socialdept/atp-signals" title="Latest Version on Packagist"><img src="https://img.shields.io/packagist/v/socialdept/atp-signals.svg?style=flat-square"></a>
10 <a href="https://packagist.org/packages/socialdept/atp-signals" title="Total Downloads"><img src="https://img.shields.io/packagist/dt/socialdept/atp-signals.svg?style=flat-square"></a>
11 <a href="https://github.com/socialdept/atp-signals/actions/workflows/tests.yml" title="GitHub Tests Action Status"><img src="https://img.shields.io/github/actions/workflow/status/socialdept/atp-signals/tests.yml?branch=main&label=tests&style=flat-square"></a>
12 <a href="LICENSE" title="Software License"><img src="https://img.shields.io/github/license/socialdept/atp-signals?style=flat-square"></a>
13</p>
14
15---
16
17## What is Signal?
18
19**Signal** is a Laravel package that lets you respond to real-time events from the AT Protocol network. Build reactive applications, custom feeds, moderation tools, analytics systems, and AppViews by listening to posts, likes, follows, and other social interactions as they happen across Bluesky and the entire AT Protocol ecosystem.
20
21Think of it as Laravel's event listeners, but for the decentralized social web.
22
23## Why use Signal?
24
25- **Laravel-style code** - Familiar patterns you already know
26- **Real-time processing** - React to events as they happen
27- **Dual-mode support** - Choose Jetstream (efficient JSON) or Firehose (comprehensive CBOR)
28- **AppView ready** - Full support for custom collections and protocols
29- **Production features** - Queue integration, cursor management, auto-reconnection
30- **Easy filtering** - Target specific collections, operations, and users with wildcards
31- **Built-in testing** - Test your signals with sample data
32
33## Quick Example
34
35```php
36use SocialDept\AtpSignals\Events\SignalEvent;
37use SocialDept\AtpSignals\Signals\Signal;
38
39class NewPostSignal extends Signal
40{
41 public function eventTypes(): array
42 {
43 return ['commit'];
44 }
45
46 public function collections(): ?array
47 {
48 return ['app.bsky.feed.post'];
49 }
50
51 public function handle(SignalEvent $event): void
52 {
53 $record = $event->getRecord();
54
55 logger()->info('New post created', [
56 'did' => $event->did,
57 'text' => $record->text ?? null,
58 ]);
59 }
60}
61```
62
63Run `php artisan signal:consume` and start responding to every post on Bluesky in real-time.
64
65## Installation
66
67```bash
68composer require socialdept/atp-signals
69php artisan signal:install
70```
71
72That's it. [Read the installation docs →](docs/installation.md)
73
74## Getting Started
75
76Once installed, you're three steps away from consuming AT Protocol events:
77
78### 1. Create a Signal
79
80```bash
81php artisan make:signal NewPostSignal
82```
83
84### 2. Define What to Listen For
85
86```php
87public function collections(): ?array
88{
89 return ['app.bsky.feed.post'];
90}
91```
92
93### 3. Start Consuming
94
95```bash
96php artisan signal:consume
97```
98
99Your Signal will now handle every matching event from the network. [Read the quickstart guide →](docs/quickstart.md)
100
101## What can you build?
102
103- **Custom feeds** - Curate content based on your own algorithms
104- **Moderation tools** - Detect and flag problematic content automatically
105- **Analytics platforms** - Track engagement, trends, and network growth
106- **Social integrations** - Mirror content to other platforms in real-time
107- **Notification systems** - Alert users about relevant activity
108- **AppViews** - Build custom AT Protocol applications with your own collections
109
110## Documentation
111
112**Getting Started**
113- [Installation](docs/installation.md) - Detailed setup instructions
114- [Quickstart Guide](docs/quickstart.md) - Build your first Signal
115- [Jetstream vs Firehose](docs/modes.md) - Choose the right mode
116
117**Building Signals**
118- [Creating Signals](docs/signals.md) - Complete Signal reference
119- [Filtering Events](docs/filtering.md) - Target specific collections and operations
120- [Queue Integration](docs/queues.md) - Process events asynchronously
121
122**Advanced**
123- [Configuration](docs/configuration.md) - All config options explained
124- [Testing](docs/testing.md) - Test your Signals
125- [Examples](docs/examples.md) - Real-world use cases
126
127## Example Use Cases
128
129### Track User Growth
130```php
131public function collections(): ?array
132{
133 return ['app.bsky.graph.follow'];
134}
135```
136
137### Monitor Content Moderation
138```php
139public function collections(): ?array
140{
141 return ['app.bsky.feed.*'];
142}
143
144public function shouldQueue(): bool
145{
146 return true; // Process in background
147}
148```
149
150### Build Custom Collections (AppView)
151```php
152public function collections(): ?array
153{
154 return ['app.yourapp.custom.collection'];
155}
156```
157
158[See more examples →](docs/examples.md)
159
160## Key Features Explained
161
162### Jetstream vs Firehose
163
164Signal supports two modes for consuming AT Protocol events:
165
166- **Jetstream** (default) - Simplified JSON events with server-side filtering
167- **Firehose** - Raw CBOR/CAR format with client-side filtering
168
169[Learn more about modes →](docs/modes.md)
170
171### Wildcard Filtering
172
173Match multiple collections with patterns:
174
175```php
176public function collections(): ?array
177{
178 return [
179 'app.bsky.feed.*', // All feed events
180 'app.bsky.graph.*', // All graph events
181 'app.yourapp.*', // All your custom collections
182 ];
183}
184```
185
186[Learn more about filtering →](docs/filtering.md)
187
188### Queue Integration
189
190Process events asynchronously for better performance:
191
192```php
193public function shouldQueue(): bool
194{
195 return true;
196}
197```
198
199[Learn more about queues →](docs/queues.md)
200
201## Available Commands
202
203```bash
204# Install Signal
205php artisan signal:install
206
207# Create a new Signal
208php artisan make:signal YourSignal
209
210# List all registered Signals
211php artisan signal:list
212
213# Start consuming events
214php artisan signal:consume
215
216# Test a Signal with sample data
217php artisan signal:test YourSignal
218```
219
220## Requirements
221
222- PHP 8.2+
223- Laravel 11+
224- WebSocket support (enabled by default)
225
226## Resources
227
228- [AT Protocol Documentation](https://atproto.com/)
229- [Bluesky API Docs](https://docs.bsky.app/)
230- [Firehose Documentation](https://docs.bsky.app/docs/advanced-guides/firehose)
231- [Jetstream Documentation](https://github.com/bluesky-social/jetstream)
232
233## Support & Contributing
234
235Found a bug or have a feature request? [Open an issue](https://github.com/socialdept/atp-signals/issues).
236
237Want to contribute? We'd love your help! Check out the [contribution guidelines](CONTRIBUTING.md).
238
239## Credits
240
241- [Miguel Batres](https://batres.co) - founder & lead maintainer
242- [All contributors](https://github.com/socialdept/atp-signals/graphs/contributors)
243
244## License
245
246Signal is open-source software licensed under the [MIT license](LICENSE).
247
248---
249
250**Built for the Federation** • By Social Dept.