Skip to content

Commit

Permalink
Mention Psr17Factory
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Jan 27, 2023
1 parent 0fc5c6c commit a7fef17
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions discovery.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,30 @@ This type of discovery finds a factory for a PSR-17_ implementation::
}
}

PSR-17 Factory
--------------

The package also provides an ``Http\Discovery\Psr17Factory`` class that can be instantiated
to get a generic PSR-17 factory::

use Http\Discovery\Psr17Factory;

$factory = new Psr17Factory();

// use any PSR-17 methods, e.g.
$request = $factory->createRequest();

Internally, this class relies on the concrete PSR-17 factories that are installed in your project.

``Psr17Factory`` provides two additional methods that allow creating
server requests or URI objects from the PHP super-globals::

$serverRequest = $factory->createServerRequestFromGlobals();
$uri = $factory->createUriFromGlobals();

.. versionadded:: 1.15
The ``Psr17Factory`` class is available since version 1.15.

PSR-18 Client Discovery
-----------------------

Expand Down

0 comments on commit a7fef17

Please sign in to comment.