1. Go to this page and download the library: Download igorw/event-source library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
igorw / event-source example snippets
use Igorw\EventSource\Stream;
foreach (Stream::getHeaders() as $name => $value) {
header("$name: $value");
}
use Igorw\EventSource\Stream;
$stream = new Stream();
while (true) {
$stream
->event()
->setData("Hello World")
->end()
->flush();
sleep(2);
}