Skip to content

Comments

Server-sent events#347

Merged
freost merged 4 commits intomasterfrom
server-sent-events
Feb 19, 2026
Merged

Server-sent events#347
freost merged 4 commits intomasterfrom
server-sent-events

Conversation

@freost
Copy link
Member

@freost freost commented Feb 18, 2026

Type


Yes/No
Bugfix? -
New feature? Yes
Other? -

Additional information

Yes/No
Has backwards compatibility breaks? No
Has unit and/or integration tests? Yes

Description


This new response sender allows you to send server-sent events from your backend.

<?php

namespace app\http\controllers;

use mako\http\response\senders\EventStream;
use mako\http\response\senders\stream\event\Event;
use mako\http\response\senders\stream\event\Field;
use mako\http\response\senders\stream\event\Type;

class Example
{
	public function __invoke(): EventStreamResponse
	{
		set_time_limit(0);

		return new EventStream(function () {
			for ($i = 0; $i < 20; $i++) {
				yield new Event(
					new Field(Type::DATA, "data frame {$i}"),
				);

				sleep(1);
			}
		});
	}
}

@freost freost changed the title WIP Server-sent events Feb 18, 2026
@freost freost marked this pull request as ready for review February 19, 2026 09:52
@freost freost merged commit aa89bba into master Feb 19, 2026
4 checks passed
@freost freost deleted the server-sent-events branch February 19, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant