diff --git a/message/message-factory.rst b/message/message-factory.rst index d5d064e..bb42755 100644 --- a/message/message-factory.rst +++ b/message/message-factory.rst @@ -29,3 +29,27 @@ This package provides interfaces for PSR-7 factories including: - ``StreamFactory`` - ``UploadedFileFactory`` - WIP (PRs welcome) - ``UriFactory`` + +Implementation for the interfaces above for `Diactoros`_ and `Guzzle PSR-7`_ can be found in ``php-http/message``. + +.. code:: php + + // Create a PSR-7 request + $factory = new Http\Message\MessageFactory\DiactorosMessageFactory(); + $request = $factory->createRequest('GET', 'http://example.com'); + + // Create a PSR-7 stream + $factory = new Http\Message\StreamFactory\DiactorosStreamFactory(); + $stream = $factory->createStream('stream content'); + +You could also use :doc:`/discovery` to find an installed factory automatically. + +.. code:: php + + // Create a PSR-7 request + $factory = MessageFactoryDiscovery::find(); + $request = $factory->createRequest('GET', 'http://example.com'); + + +.. _Diactoros: https://github.com/zendframework/zend-diactoros +.. _Guzzle PSR-7: https://github.com/guzzle/psr7