{"record":{"id":"682d42ae54973553","repo":"w7corp/easywechat","slug":"you-cannot-use-the-symfony-component-httpclient-h","errorCode":null,"errorMessage":"You cannot use the \"Symfony\\Component\\HttpClient\\HttplugClient\" as no PSR-17 factories have been found. Try running \"composer require nyholm/psr7\".","messagePattern":"You cannot use the \"Symfony\\\\Component\\\\HttpClient\\\\HttplugClient\" as no PSR-17 factories have been found\\. Try running \"composer require nyholm/psr7\"\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"src/Kernel/HttpClient/Response.php","lineNumber":163,"sourceCode":"    }\n\n    public function toPsrResponse(?ResponseFactoryInterface $responseFactory = null, ?StreamFactoryInterface $streamFactory = null): \\Psr\\Http\\Message\\ResponseInterface\n    {\n        $streamFactory ??= $responseFactory instanceof StreamFactoryInterface ? $responseFactory : null;\n\n        if ($responseFactory === null || $streamFactory === null) {\n            if (! class_exists(Psr17Factory::class) && ! class_exists(Psr17FactoryDiscovery::class)) {\n                throw new \\LogicException('You cannot use the \"Symfony\\Component\\HttpClient\\Psr18Client\" as no PSR-17 factories have been provided. Try running \"composer require nyholm/psr7\".');\n            }\n\n            try {\n                $psr17Factory = class_exists(Psr17Factory::class, false) ? new Psr17Factory : null;\n                $responseFactory ??= $psr17Factory ?? Psr17FactoryDiscovery::findResponseFactory(); /** @phpstan-ignore-line */\n                $streamFactory ??= $psr17Factory ?? Psr17FactoryDiscovery::findStreamFactory(); /** @phpstan-ignore-line */\n\n                /** @phpstan-ignore-next-line */\n            } catch (NotFoundException $e) {\n                throw new \\LogicException('You cannot use the \"Symfony\\Component\\HttpClient\\HttplugClient\" as no PSR-17 factories have been found. Try running \"composer require nyholm/psr7\".', 0, $e);\n            }\n        }\n\n        $psrResponse = $responseFactory->createResponse($this->getStatusCode());\n\n        foreach ($this->getHeaders(false) as $name => $values) {\n            foreach ($values as $value) {\n                $psrResponse = $psrResponse->withAddedHeader($name, $value);\n            }\n        }\n\n        $body = $this->response instanceof StreamableInterface ? $this->toStream(false) : StreamWrapper::createResource($this->response);\n        $body = $streamFactory->createStreamFromResource($body);\n\n        if ($body->isSeekable()) {\n            $body->seek(0);\n        }\n","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/w7corp/easywechat/blob/f0cf0a8b8361417ed683b8246d0ecbaf0aafcaa8/src/Kernel/HttpClient/Response.php#L145-L181","documentation":"The discovery fallback of Response::toPsrResponse(): php-http/discovery exists, but Psr17FactoryDiscovery::findResponseFactory()/findStreamFactory() throws NotFoundException because no PSR-17 implementation package (nyholm/psr7, guzzlehttp/psr7, ...) is installed for it to find. The NotFoundException is rethrown as this LogicException (worded for the HttplugClient) with the original chained as previous.","triggerScenarios":"Calling toPsrResponse() with no factory arguments when php-http/discovery is present but every concrete PSR-17 implementation has been removed or was never installed.","commonSituations":"composer require php-http/discovery without an implementation, dependency pruning in optimized builds, conflicting discovery caches after package changes.","solutions":["composer require nyholm/psr7 (or guzzlehttp/psr7) to give discovery an implementation to find","Or bypass discovery entirely by passing ResponseFactoryInterface and StreamFactoryInterface to toPsrResponse()","Run composer dump-autoload / clear caches after changing PSR-7 packages so discovery picks them up"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Ensure an implementation exists for discovery before calling\n$hasPsr17 = class_exists(\\Nyholm\\Psr7\\Factory\\Psr17Factory::class)\n    || class_exists(\\GuzzleHttp\\Psr7\\HttpFactory::class);\nif (! $hasPsr17) {\n    throw new LogicException('No PSR-17 implementation installed; run: composer require nyholm/psr7');\n}\n$psr7 = $response->toPsrResponse();","typeGuard":null,"tryCatchPattern":"try {\n    $psr7 = $response->toPsrResponse();\n} catch (\\LogicException $e) {\n    if (str_contains($e->getMessage(), 'PSR-17')) {\n        // fall back to the wrapper API instead of a PSR-7 conversion\n        $data = $response->toArray();\n    } else {\n        throw $e;\n    }\n}","preventionTips":["Add nyholm/psr7 (or guzzlehttp/psr7) to composer.json when PSR-7 interop is required","Pass factories explicitly to decouple from package presence at runtime"],"tags":["php","easywechat","psr-7","psr-17","dependencies","service-discovery"],"backgroundTag":"missing-psr17-factories","analyzedSha":"f0cf0a8b8361417ed683b8246d0ecbaf0aafcaa8","analyzedAt":"2026-08-21T05:29:19.565Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}