Guzzlehttp/psr7 is a proficient library in PHP that provides a robust PSR-7 message implementation for developers. It has stream decorators and offers other functions such as query string parsing. This package provides assorted stream implementations and stream decorators. Notably, it also handles installation using composer, stream management, and includes guidelines for upgrading from the Function API.
To utilize Guzzlehttp/psr7, you'll need to install it via composer by running the command
composer require guzzlehttp/psr7. To make use of various streams, simply use the
use statement to bring them into your scope, and create new instances as required. For example,
use GuzzleHttp\Psr7; $a = Psr7\Utils::streamFor('abc, '); $b = Psr7\Utils::streamFor('123.'); $composed = new Psr7\AppendStream([$a, $b]); $composed->addStream(Psr7\Utils::streamFor(' Above all listen to me')); echo $composed; // abc, 123. Above all listen to me.
To apply stream decorators, use the
DecoratorTrait and implement your custom methods. All operations, such as reading from the stream, seeking positions, writing to it, are handled through the utilities offered by this package.
You'll find the official documentation for Guzzlehttp/psr7 on its GitHub repository at https://github.com/guzzle/psr7. Here, you'll get detailed explanations, practical examples, and a comprehensive guide on how to use the package effectively.