1

I'm using Symfony 6 and Flysystem 3, and depending on a parameter I want to pick one of the 2 adapters I have.

I don't want to instantiate both of them in the constructor since I'm only using 1 per execution (it's a Consumer).

Tried to instantiate the Container and use $container->get('my.adapter'):

public function __construct(
        private readonly ContainerInterface $container
    ) {
    }

However I'm missing something:

Cannot autowire service "App\Consumer\MyConsumer": argument "$container" of method "__construct()" references interface "Symfony\Component\DependencyInjection\ContainerInte rface" but no such service exists. You should maybe alias this interface to the existing "service_container" service.

Any ideas??

  • you might look into using the [mount manager](https://flysystem.thephpleague.com/docs/advanced/mount-manager/) – craigh Oct 20 '22 at 12:02
  • Think I jumped that in the documentation, thanks for letting me know, looking into that, it seems promissing! – guilherme.souza Oct 22 '22 at 17:41

0 Answers0