Skip to content

You cannot use the "Symfony\Component\HttpClient\Psr18Client" as the "psr/http-client" package is not installed #248

Closed
@brettmc

Description

@brettmc

PHP version: 8.2.0

Description
php-http/discovery plugin installs a psr18 client that cannot be discovered

How to reproduce
composer.json:

{
  "config": {
    "allow-plugins": {
      "php-http/discovery": true
    }
  },
  "require": {
    "php-http/client-implementation": "^1.0",
    "php-http/discovery": "^1.18"
  }
}

test.php:

<?php
require 'vendor/autoload.php';
$client = \Http\Discovery\Psr18ClientDiscovery::find();
var_dump(get_class($client));
composer update
php test.php

Results:

Fatal error: Uncaught LogicException: You cannot use the "Symfony\Component\HttpClient\Psr18Client" as the "psr/http-client" package is not installed. Try running "composer require php-http/discovery psr/http-client-implementation:*". in /usr/src/myapp/vendor/symfony/http-client/Psr18Client.php on line 37

Possible Solution
As a workaround, I could require psr/http-client, but we don't directly require or use it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions