spatie/twitter-streaming-api
Laravel-friendly PHP client for Twitter’s Streaming API. Keep an open HTTPS connection and react to tweets and user events in real time (no polling). Easily filter streams, listen for keywords/mentions, and handle incoming tweet payloads with callbacks.
guzzlehttp/guzzle and symfony/http-client), reducing bloat. Works alongside existing Twitter API clients (e.g., abraham/twitteroauth).spatie/twitter-api) or rewrite critical logic using symfony/http-client.TweetReceived).@spatie_be mentions).// app/Providers/TwitterStreamServiceProvider.php
public function register()
{
$this->app->singleton(TwitterStreamer::class, function () {
return new TwitterStreamer(
config('services.twitter.bearer_token'),
config('services.twitter.api_key'),
config('services.twitter.api_secret')
);
});
}
PublicStream::create(...)->whenHears('keyword', function (array $tweet) {
event(new TweetReceived($tweet));
});
TweetReceived::dispatch($tweet)->onQueue('tweets');
https://api.twitter.com/2/tweets/search/stream).cURL under the hood).guzzlehttp/guzzle and symfony/http-client may need updates.spatie/twitter-api) for guidance.spatie/circuit-breaker) if downstream systems (DB, APIs) lag.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Twitter API downtime | No tweets received | Exponential backoff + alerts (e.g., Laravel Nova). |
| Bearer token revoked | Stream fails | Automated token rotation (e.g., Laravel Envoy). |
| High tweet volume | DB/API overload | Batch processing + queue throttling. |
| Worker crashes | Missed tweets | Supervisor (e.g., Laravel Forge) + persistent queues. |
| PHP memory leaks | Worker OOM kills | Set memory limits (memory_limit=512M). |
How can I help you explore Laravel packages today?