From c5ae3a5de67a50e1ea5ba2f5f2f0b0cec9cce5a5 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Thu, 28 Jul 2016 19:20:56 +0200 Subject: [PATCH 1/3] Added code example of how to use message factories --- message/message-factory.rst | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/message/message-factory.rst b/message/message-factory.rst index d5d064e..7bf875d 100644 --- a/message/message-factory.rst +++ b/message/message-factory.rst @@ -20,8 +20,6 @@ The ``MessageFactory`` aims to provide an easy way to construct messages. Usage ----- -.. _stream-factory: - This package provides interfaces for PSR-7 factories including: - ``MessageFactory`` @@ -29,3 +27,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: http://docs.guzzlephp.org/en/5.3/ +.. _Guzzle PSR-7: https://github.com/guzzle/psr7 From 58ab091018d12d0417ad54f353c26eba1b9e64bc Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Thu, 28 Jul 2016 20:14:11 +0200 Subject: [PATCH 2/3] Readded the label --- message/message-factory.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/message/message-factory.rst b/message/message-factory.rst index 7bf875d..6b10c48 100644 --- a/message/message-factory.rst +++ b/message/message-factory.rst @@ -20,6 +20,8 @@ The ``MessageFactory`` aims to provide an easy way to construct messages. Usage ----- +.. _stream-factory: + This package provides interfaces for PSR-7 factories including: - ``MessageFactory`` From 6d91b5db6dd08da29f2246bc5a72ce3a422d3aeb Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 2 Aug 2016 14:16:57 +0200 Subject: [PATCH 3/3] Updated wrong link --- message/message-factory.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/message/message-factory.rst b/message/message-factory.rst index 6b10c48..bb42755 100644 --- a/message/message-factory.rst +++ b/message/message-factory.rst @@ -51,5 +51,5 @@ You could also use :doc:`/discovery` to find an installed factory automatically. $request = $factory->createRequest('GET', 'http://example.com'); -.. _Diactoros: http://docs.guzzlephp.org/en/5.3/ +.. _Diactoros: https://github.com/zendframework/zend-diactoros .. _Guzzle PSR-7: https://github.com/guzzle/psr7