1. Go to this page and download the library: Download ehough/psr7 library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ehough / psr7 example snippets
useHough\Psr7;
$a = Psr7\stream_for('abc, ');
$b = Psr7\stream_for('123.');
$composed = new Psr7\AppendStream(array($a, $b));
$composed->addStream(Psr7\stream_for(' Above all listen to me'));
echo $composed; // abc, 123. Above all listen to me.
useHough\Psr7;
// When more than 1024 bytes are in the buffer, it will begin returning// false to writes. This is an indication that writers should slow down.
$buffer = new Psr7\BufferStream(1024);
useHough\Psr7;
// Create an empty stream
$stream = Psr7\stream_for();
// Start dropping data when the stream has more than 10 bytes
$dropping = new Psr7\DroppingStream($stream, 10);
$dropping->write('01234567890123456789');
echo $stream; // 0123456789
useHough\Psr7;
$stream = Psr7\stream_for('hi');
$fnStream = Psr7\FnStream::decorate($stream, array(
'rewind' => function()use($stream){
echo'About to rewind - ';
$stream->rewind();
echo'rewound!';
}
));
$fnStream->rewind();
// Outputs: About to rewind - rewound!
useHough\Psr7;
$stream = new Psr7\LazyOpenStream('/path/to/file', 'r');
// The file has not yet been opened...echo $stream->read(10);
// The file is opened and read from only when needed.
useHough\Psr7;
$original = Psr7\stream_for(fopen('/tmp/test.txt', 'r+'));
echo $original->getSize();
// >>> 1048576// Limit the size of the body to 1024 bytes and start reading from byte 2048
$stream = new Psr7\LimitStream($original, 1024, 2048);
echo $stream->getSize();
// >>> 1024echo $stream->tell();
// >>> 0
$base = new Uri('http://example.com/a/b/');
echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c')); // prints 'c'.echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y')); // prints '../x/y'.echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'.echo UriResolver::relativize($base, new Uri('http://example.org/a/b/')); // prints '//example.org/a/b/'.
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.