8p / EightPointsGuzzleBundle

⛽️ Integrates Guzzle 6.x, a PHP HTTP Client, into Symfony
MIT License
440 stars 71 forks source link

Client service not found #254

Closed Gonzalo1987 closed 5 years ago

Gonzalo1987 commented 5 years ago
Q A
Symfony version 4.2.7
Bundle version 7.5.0

I'm feel a little stupid right now, but I don't know what is happening. When I try use one of the clients configurated in the yaml file I get:

Service "eight_points_guzzle.client.api_exchange" not found: even though it exists in the app's container, the container inside "App\Controller\DefaultController" is a smaller service locator that only knows about the "doctrine", "form.factory", "http_kernel", "parameter_bag", "request_stack", "router", "security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "session", "templating" and "twig" services. Try using dependency injection instead.

What I'm doing wrong?

The bundle seems well configured. I'm cleared the cache and installed the assets.

Thanks.

gregurco commented 5 years ago

Hello @Gonzalo1987 . I think you have 2 options: 1) Resolve this by extending Symfony\Bundle\FrameworkBundle\Controller\Controller instead of ymfony\Bundle\FrameworkBundle\Controller\AbstractController. 2) Use autowire as described here: https://github.com/8p/EightPointsGuzzleBundle/blob/master/src/Resources/doc/autowiring-clients.md

Gonzalo1987 commented 5 years ago

I'll autowire it, (since Controller is deprecated), Thank you very much, very useful!!!