Skip to content

Instantly share code, notes, and snippets.

@till
Created April 27, 2015 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save till/e7412234131e9c50ebec to your computer and use it in GitHub Desktop.
Save till/e7412234131e9c50ebec to your computer and use it in GitHub Desktop.
<?php
// an attempt to read data from a local nginx pushstream setup
$this->client = new Client('http://vm.local');
$request = $this->client->get(
'/sub/foo',
['Accept' => '*/*'],
['stream' => true],
);
$factory = new PhpStreamRequestFactory();
$stream = $factory->fromRequest($request);
$line = '';
while (!$stream->feof()) {
$line .= $stream->readLine(10); // hack
while (false !== strstr($line, $this->delimiter)) {
list($message, $line) = explode($this->delimiter, $line, 2);
$message = json_decode($message, true);
var_dump($message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment