3

I can define anonymous inline factory (Symfony 6+) like this:

GuzzleClient1:
    class: GuzzleHttp\ClientInterface
    factory: [ !service { class: 'App\GuzzleClientFactory', calls: [ { 'withBaseUri': [ 'http://example.com' ] } ] }, 'build' ]

or like this:

GuzzleClient1:
    class: GuzzleHttp\ClientInterface
    factory:
        - !service
          class: 'App\GuzzleClientFactory'
          calls:
            - withBaseUri: ['http://example.com' ]
        - 'build'

but I can't figure out the correct syntax for anonymous inline invokable factory. How do I omit method name here?

Vladislav Rastrusny
  • 29,378
  • 23
  • 95
  • 156
  • Maybe this bundle https://github.com/8p/EightPointsGuzzleBundle will be useful – Artem Dec 05 '22 at 16:04
  • @Artem Thanks, but actually I'm looking for this solution exactly to get rid of it. A simple Guzzle Client factory of 50 lines can replace the whole bundle in my project. – Vladislav Rastrusny Dec 06 '22 at 08:08

0 Answers0