Symfony2 conditional service declaration
问题 I'm currently trying to find a solid solution to change the dependencies of a Symfony2 service dynamically. In detail: I have a Services which uses a HTTP-Driver to communicate with an external API. class myAwesomeService { private $httpDriver; public function __construct( HTTDriverInterface $httpDriver ) { $this->httpDriver = $httpDriver; } public function transmitData($data) { $this->httpDriver->dispatch($data); } } While running the Behat tests on the CI, I'd like to use a httpMockDriver