Title: Psr17FactoryDiscovery
Published: May 20, 2026

---

# class Psr17FactoryDiscovery {}

## In this article

 * [Methods](https://developer.wordpress.org/reference/classes/wordpress-aiclientdependencies-http-discovery-psr17factorydiscovery/?output_format=md#methods)
 * [Source](https://developer.wordpress.org/reference/classes/wordpress-aiclientdependencies-http-discovery-psr17factorydiscovery/?output_format=md#source)

[ Back to top](https://developer.wordpress.org/reference/classes/wordpress-aiclientdependencies-http-discovery-psr17factorydiscovery/?output_format=md#wp--skip-link--target)

Finds PSR-17 factories.

## 󠀁[Methods](https://developer.wordpress.org/reference/classes/wordpress-aiclientdependencies-http-discovery-psr17factorydiscovery/?output_format=md#methods)󠁿

| Name | Description | 
| [Psr17FactoryDiscovery::createException](https://developer.wordpress.org/reference/classes/wordpress-aiclientdependencies-http-discovery-psr17factorydiscovery/createexception/) | – | 
| [Psr17FactoryDiscovery::findRequestFactory](https://developer.wordpress.org/reference/classes/wordpress-aiclientdependencies-http-discovery-psr17factorydiscovery/findrequestfactory/) | – | 
| [Psr17FactoryDiscovery::findResponseFactory](https://developer.wordpress.org/reference/classes/wordpress-aiclientdependencies-http-discovery-psr17factorydiscovery/findresponsefactory/) | – | 
| [Psr17FactoryDiscovery::findServerRequestFactory](https://developer.wordpress.org/reference/classes/wordpress-aiclientdependencies-http-discovery-psr17factorydiscovery/findserverrequestfactory/) | – | 
| [Psr17FactoryDiscovery::findStreamFactory](https://developer.wordpress.org/reference/classes/wordpress-aiclientdependencies-http-discovery-psr17factorydiscovery/findstreamfactory/) | – | 
| [Psr17FactoryDiscovery::findUploadedFileFactory](https://developer.wordpress.org/reference/classes/wordpress-aiclientdependencies-http-discovery-psr17factorydiscovery/finduploadedfilefactory/) | – | 
| [Psr17FactoryDiscovery::findUriFactory](https://developer.wordpress.org/reference/classes/wordpress-aiclientdependencies-http-discovery-psr17factorydiscovery/findurifactory/) | – | 
| [Psr17FactoryDiscovery::findUrlFactory](https://developer.wordpress.org/reference/classes/wordpress-aiclientdependencies-http-discovery-psr17factorydiscovery/findurlfactory/) |  — deprecated |

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wordpress-aiclientdependencies-http-discovery-psr17factorydiscovery/?output_format=md#source)󠁿

    ```php
    final class Psr17FactoryDiscovery extends ClassDiscovery
    {
        private static function createException($type, Exception $e)
        {
            return new RealNotFoundException('No PSR-17 ' . $type . ' found. Install a package from this list: https://packagist.org/providers/psr/http-factory-implementation', 0, $e);
        }
        /**
         * @return RequestFactoryInterface
         *
         * @throws RealNotFoundException
         */
        public static function findRequestFactory()
        {
            try {
                $messageFactory = static::findOneByType(RequestFactoryInterface::class);
            } catch (DiscoveryFailedException $e) {
                throw self::createException('request factory', $e);
            }
            return static::instantiateClass($messageFactory);
        }
        /**
         * @return ResponseFactoryInterface
         *
         * @throws RealNotFoundException
         */
        public static function findResponseFactory()
        {
            try {
                $messageFactory = static::findOneByType(ResponseFactoryInterface::class);
            } catch (DiscoveryFailedException $e) {
                throw self::createException('response factory', $e);
            }
            return static::instantiateClass($messageFactory);
        }
        /**
         * @return ServerRequestFactoryInterface
         *
         * @throws RealNotFoundException
         */
        public static function findServerRequestFactory()
        {
            try {
                $messageFactory = static::findOneByType(ServerRequestFactoryInterface::class);
            } catch (DiscoveryFailedException $e) {
                throw self::createException('server request factory', $e);
            }
            return static::instantiateClass($messageFactory);
        }
        /**
         * @return StreamFactoryInterface
         *
         * @throws RealNotFoundException
         */
        public static function findStreamFactory()
        {
            try {
                $messageFactory = static::findOneByType(StreamFactoryInterface::class);
            } catch (DiscoveryFailedException $e) {
                throw self::createException('stream factory', $e);
            }
            return static::instantiateClass($messageFactory);
        }
        /**
         * @return UploadedFileFactoryInterface
         *
         * @throws RealNotFoundException
         */
        public static function findUploadedFileFactory()
        {
            try {
                $messageFactory = static::findOneByType(UploadedFileFactoryInterface::class);
            } catch (DiscoveryFailedException $e) {
                throw self::createException('uploaded file factory', $e);
            }
            return static::instantiateClass($messageFactory);
        }
        /**
         * @return UriFactoryInterface
         *
         * @throws RealNotFoundException
         */
        public static function findUriFactory()
        {
            try {
                $messageFactory = static::findOneByType(UriFactoryInterface::class);
            } catch (DiscoveryFailedException $e) {
                throw self::createException('url factory', $e);
            }
            return static::instantiateClass($messageFactory);
        }
        /**
         * @return UriFactoryInterface
         *
         * @throws RealNotFoundException
         *
         * @deprecated This will be removed in 2.0. Consider using the findUriFactory() method.
         */
        public static function findUrlFactory()
        {
            return static::findUriFactory();
        }
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/php-ai-client/third-party/http/discovery/psr17factorydiscovery.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/php-ai-client/third-party/Http/Discovery/Psr17FactoryDiscovery.php#L18)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/php-ai-client/third-party/Http/Discovery/Psr17FactoryDiscovery.php#L18-L119)

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwordpress-aiclientdependencies-http-discovery-psr17factorydiscovery%2F)
before being able to contribute a note or feedback.