Download the PHP package nerdofcode/laravel-sse without Composer
On this page you can find all versions of the php package nerdofcode/laravel-sse. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nerdofcode/laravel-sse
More information about nerdofcode/laravel-sse
Files in nerdofcode/laravel-sse
Package laravel-sse
Short Description Server-Sent Events (SSE) library for Laravel
License MIT
Informations about the package laravel-sse
Laravel SSE (Server-Sent Events)
A simple Server-Sent Events (SSE) library for Laravel apps.
🚀 Quick Start
Try it now without installing Laravel:
Then open http://localhost:8000 in your browser!
See QUICKSTART.md for more details.
Features
- Easy integration with Laravel
- Fluent API for sending events
- Support for event types and IDs
- Auto-reconnection handling
- Connection status monitoring
- JSON and text event support
- Keep-alive comments
- Configurable retry times
- Multiple usage patterns
Installation
Install via Composer:
The package will automatically register its service provider.
Publish Configuration (Optional)
This will create config/sse.php where you can configure default settings.
Basic Usage
Method 1: Using the Facade
Method 2: Using Dependency Injection
Method 3: Using the Helper
API Reference
Creating Streams
stream(callable $callback)
Create a custom SSE stream with full control:
create(callable $generator, int $interval = 1)
Create a simple auto-streaming SSE response:
Sending Events
event(string $data, ?string $event = null, ?string $id = null)
Send a custom event:
message(string $data, ?string $id = null)
Send a simple message (alias for event with data only):
json(array|object $data, ?string $event = null, ?string $id = null)
Send JSON data:
comment(string $comment)
Send a comment (keeps connection alive):
Configuration Methods
setRetry(int $milliseconds)
Set reconnection retry time:
setEventId(?string $id)
Set default event ID:
setHeader(string $key, string $value)
Add custom header:
setExecutionTime(int $seconds)
Set maximum execution time (0 = unlimited):
Utility Methods
isConnected()
Check if client is still connected:
stop()
Stop the stream:
Client-Side (JavaScript)
Examples
Real-time Counter
Progress Monitor
Live Notifications
Testing
The package includes a comprehensive test suite.
Running Tests
Test Coverage
- ✅ SSE class methods and configuration
- ✅ Event formatting and output
- ✅ Service provider registration
- ✅ Facade functionality
- ✅ Integration tests for streaming
- ✅ Standalone SSE implementation
See tests/README.md for more details.
Configuration
Edit config/sse.php:
Or use .env:
Requirements
- PHP >= 8.0
- Laravel >= 9.0
License
MIT License
All versions of laravel-sse with dependencies
illuminate/support Version ^11.0|^12.0
illuminate/http Version ^11.0|^12.0