marko/sse

Server-Sent Events (SSE) support for Marko Framework

Maintainers

Package info

github.com/marko-php/marko-sse

Type:marko-module

pkg:composer/marko/sse

Statistics

Installs: 5

Dependents: 0

Suggesters: 0

Stars: 0

0.0.1 2026-03-25 17:53 UTC

This package is auto-updated.

Last update: 2026-03-25 21:07:44 UTC


README

Server-Sent Events for Marko — push real-time updates to browsers without WebSockets.

Installation

composer require marko/sse

Quick Example

use Marko\Sse\SseEvent;
use Marko\Sse\SseStream;
use Marko\Sse\StreamingResponse;

$stream = new SseStream(
    dataProvider: function () use (&$lastEventId): array {
        $messages = $this->messages->findSince($lastEventId);

        return array_map(fn ($msg) => new SseEvent(
            data: ['id' => $msg->id, 'text' => $msg->body],
            event: 'message',
            id: $msg->id,
        ), $messages);
    },
    pollInterval: 1,
    timeout: 300,
);

return new StreamingResponse($stream);

Documentation

Full usage, API reference, and examples: marko/sse