after playing with containers in zend-expressive and noticing some inconsistencies between container implementations I would like to know how you do to make a instance shareable between calls for container->get() independently of the container you are using. Is that possible?
PSR-11 suggests (SHOULD) to return an already instantiated instance if one was already created by the container. It means it should return one instance for the same container->get() calls. Since it is a suggestion, it’s OK for container implementations to work differently.
It means it would be our responsibility to assure that it works the way we want consistently. In other words, Expressive should take care of that:
- Expressive should have a way (common to all containers) to express if an instance will be shared or not.
- If an instance are configured one way or another. Expressive should allow specific calls to $container->get() to work differently based on the developer wiliness. Probably using extra (and optional) parameters to the
What do you think?