Custom arguments on container instantiation


When I call $this->get('myService') is it possible to somehow pass some custom arguments to that?

For example when registering it I do

$container['myService']=function() use($container) { return new myService($container, $pass_optional_parameters_here_called_from_the_above_get);};

Is this possible?

Thanks in advance

According to PSR-11 (Container Interface) this is not (directly) possible.

However, if you retrieve a factory object from the container and create the object via the factory, it is possible to pass user-defined parameters.