If I have a simple definition for a Guzzle client for instance in my production environment:
GuzzleHttpClient: ~
This will ensure a guzzle client is always injectable, that works fine.
But in the dev
environment I’d want to make the client with a custom factory that attaches all kinds of debugging middleware and configurations, so I’d put this in my services_dev.yml
GuzzleHttpClient:
factory: ['@FactoriesGuzzleFactory', 'createClient']
arguments:
- handler: '@custom.debugging.guzzle.stack'
That also works great, provided I directly use a GuzzleHttpClient in my constructor.
But things start to break when I have custom services of this class, that would extend it more.
custom.client:
class: GuzzleHttpClient
arguments:
- handler: '@custom.guzzle.stack'
I’d want this custom.client
to be made with the factory ONLY in the dev environment.
Even though it’s defined as a class of type GuzzleHttpClient, the GuzzleHttpClient factory in the overridden definition is not used.
What am I doing wrong? Ideally I don’t want to define the factory in my production.yml because it is purely used for adding debugging info