Download the PHP package andreagroferreira/redis-stream without Composer
On this page you can find all versions of the php package andreagroferreira/redis-stream. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download andreagroferreira/redis-stream
More information about andreagroferreira/redis-stream
Files in andreagroferreira/redis-stream
Package redis-stream
Short Description A powerful, reliable Redis Streams implementation for Laravel applications
License MIT
Homepage https://github.com/andreagroferreira/laravel-redis-stream
Informations about the package redis-stream
Redis Stream Package for Laravel
A powerful, reliable Redis Streams implementation for Laravel applications. This package makes it easy to work with Redis Streams for event-driven applications, message processing, and real-time data pipelines.
Features
-
β Proper exception handling with typed exceptions
- π Simple producer/consumer API for Redis Streams
- β»οΈ Compatible with both phpredis and predis drivers
- π Automatic consumer group management
- π Retry handling for failed messages
- π Batch publishing support for high-throughput applications
- π Graceful shutdown support
- βοΈ Configurable stream trimming (MAXLEN)
- π Built-in Artisan command for consuming streams
Installation
You can install the package via composer:
Redis Driver Requirements
This package supports both phpredis
(the PHP extension) and predis
(PHP library) drivers:
For PHP Redis Extension (recommended for production):
For Predis Library:
The package will automatically detect which driver you're using.
After installation, publish the configuration file:
Configuration
Configure your Redis connection for streams in your .env
file:
You can also define custom streams in the redis_stream.php
config file.
Usage
Exception Handling
This package provides specific exception types for better error handling:
RedisStreamException
: Base exception class for all Redis Stream errorsConnectionException
: Thrown when Redis connection failsPublishException
: Thrown when message publishing failsConsumeException
: Thrown when message consumption failsMessageProcessingException
: Thrown when message processing fails
Example of handling exceptions:
Basic Example
Using the Artisan Command
Creating a Custom Handler
Batch Publishing
For high-throughput scenarios, you can publish messages in batches:
Stream Trimming
To manage stream size:
Creating Custom Stream Producers
You can access named stream producers defined in your config:
Generating Custom Producers and Consumers
This package provides Artisan commands to quickly scaffold custom producer and consumer classes:
Creating a Producer
This will generate an OrderProducer
class that extends the base functionality of RedisStreamProducer
.
Creating a Consumer
The --command
flag will also generate a dedicated Artisan command to run this consumer:
Consumer Implementation Example
After generating a consumer, you can customize the handleMessage
method to process specific event types:
Testing
This package uses Pest PHP for testing:
For code coverage:
Note: To run the full test suite including feature tests, you need to have Redis installed and configured locally. The feature tests interact with an actual Redis server to verify the Redis Stream functionality.
The tests include both unit tests for exceptions and feature tests for Redis Stream interactions. In our CI setup, we only verify basic functionality to avoid Redis configuration issues in automated environments.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- AndrΓ© Ferreira
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of redis-stream with dependencies
illuminate/support Version ^9.0|^10.0|^12.0
illuminate/console Version ^9.0|^10.0|^12.0
illuminate/filesystem Version ^9.0|^10.0|^12.0