volkerschulz / sse-client
Client for Server-Sent Events
0.9.2
2025-02-09 09:46 UTC
Requires
- php: >=8.1.0
- guzzlehttp/guzzle: ^7.9
This package is auto-updated.
Last update: 2025-04-27 00:08:28 UTC
README
Client to receive server-sent events (from OpenAI API runner for example)
Installation
The recommended way to install SseClient is through Composer.
composer require volkerschulz/sse-client
Usage
Minimal:
use volkerschulz\SseClient; $client = new SseClient('https://example.com'); foreach($client->getEvents() as $event) { // Handle single event echo $event->getData(); }
POST request w/ options:
use volkerschulz\SseClient; $sse_options = [ 'reconnect' => false, 'read_timeout' => 5 ]; $client = new SseClient('https://example.com', $sse_options); $http_options = [ 'json' => [ 'foo' => 'bar' ], 'allow_redirects' => false ]; foreach($client->getEvents($http_options, 'POST') as $event) { // Handle single event }
Security
If you discover a security vulnerability within this package, please send an email to security@volkerschulz.de. All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced.
License
This package is made available under the MIT License (MIT). Please see License File for more information.