Hi all,
I try to register activity with extra dependency in worker.php. PHPDoc of WorkerInterface::registerActivity() method says that I should provide a callback to inject a dependency:
But I’m confusing with $container variable: should I get instance of my Symfony Container here (I use Temporal PHP SDK as Composer dependency in my Symfony application) or should I implement my own container class?
Hi @Inessa_M
I asked our PHP experts to take a look and provide info.
From what I can tell (could be wrong) you don’t need that $container var but can just pass in a function that returns your activity impl, see here. I also think you can pass in depends to your activity constructor when you create your activity instance.
Hope it is not too late to add an example to the answer.
This is a working example of how to get access to the Symfony container. The Runtime class here is autowired, so there is no need for additional configuration.