8000 [HttpClient] HttplugClient autowiring error · Issue #676 · symfony/recipes · GitHub
[go: up one dir, main page]

Skip to content

[HttpClient] HttplugClient autowiring error #676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
8000
1ed opened this issue Nov 14, 2019 · 3 comments · Fixed by symfony/symfony#34390
Closed

[HttpClient] HttplugClient autowiring error #676

1ed opened this issue Nov 14, 2019 · 3 comments · Fixed by symfony/symfony#34390

Comments

@1ed
Copy link
1ed commented Nov 14, 2019

Hello!

When I try to autowire HttplugClient like this:

<?php declare(strict_types=1);

namespace App\Controller;

use Http\Client\HttpClient;
use Symfony\Component\Routing\Annotation\Route;

/**
 * @Route(name="app_index", path="", methods={"GET"})
 */
class IndexController
{
    private $httpClient;

    public function __construct(HttpClient $httpClient)
    {
        $this->httpClient = $httpClient;
    }

    public function __invoke()
    {
        var_dump($this->httpClient);
    }
}

I get this error

Argument 2 passed to Symfony\Component\HttpClient\HttplugClient::__construct() must be an instance of Psr\Http\Message\ResponseFactoryInterface or null, instance of Nyholm\Psr7\Factory\HttplugFactory

I think it should work out of the box because the aliases provided by https://github.com/symfony/recipes/blob/master/nyholm/psr7/1.0/config/packages/nyholm_psr7.yaml

It's a bug or am I missing something?

Steps to reproduce:

$ composer create-project symfony/skeleton my-project -s dev
$ cd my-project
$ composer req annotations http-client php-http/httplug nyholm/psr7
$ # copy the code above to src/Controller/IndexController.php
$ symfony serve
$ # and open the home page 

Thanks for your help!

@1ed
Copy link
Author
1ed commented Nov 15, 2019

@Nyholm @nicolas-grekas maybe you have some pointers for me about this? Thank you!

@nicolas-grekas
Copy link
Member

See symfony/symfony#34390

@1ed
Copy link
Author
1ed commented Nov 15, 2019

It was quick! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0