--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+unsubscribe@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/CAJp_myX6QenJQtgmkDYRmJp6ffEaCfO3gDDKHOur1Sq4biLWRw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
> The only concern to me is
> https://github.com/container-interop/container-interop/issues/69 regarding
> return value of get .
>
> Basically this is the text :
>
> Two successive calls to get with the same identifier SHOULD return the same
> value. However, depending on the implementor design and/or user
> configuration, different values might be returned, so user SHOULD NOT rely
> on getting the same value on 2 successive calls.
>
> I don't want to drag everyone again to the same discussion. But I wonder if
> there is any implementors having any concern about the same.
No issues from my POV as maintainer on zend-servicemanager.
The reason is thus: we have always supported a concept of "shared"
services. Services are shared by default, but when configuring the
container, you can mark a service as "not shared"; this can be useful
when a particular service *should* have multiple instances.
As an
example, our EventManager is not designed to be shared between
different services, but has a constructor pattern that *does* require
access to other services, and thus management by the container.
Similarly, Pimple 1 separated shared from unshared services, and v3
allows you to make services unshared by mapping a service to the
return of the container's factory() method.
While it could be considered niche functionality, having the ability
to act in this way covers a more generalized set of functionality,
which, more importantly, is already seen in existing implementations,
making it useful to the specification.
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+unsubscribe@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/2c879363-54ca-4723-8a6e-01c1c9917718%40googlegroups.com.
A container, like the name says, should "contain" services, not create services on each call, return them and then discard them.
2016-10-27 11:04 GMT-02:00 Pedro Cordeiro <pedro.c...@sympla.com.br>:
> Just like @mwop, I've never had an issue with this behaviour.
> Actually, I'd be interested in knowing what is your concern with this? Do you have an actual use case in mind that absolutely requires the container to always return the same value for all entries?A simple example is an event dispatcher. If I register a listener on one instance of the dispatcher and trigger an event on another instance of the dispatcher, my registered listeners will not be called. Again, this is an application concern, not a framework concern and it could be argued that this kind of issue is out-of-scope for this PSR.
But overall, I agree with Hari that the main use case for a container is to instance the service once and always return the same instance on further calls. If you retrieve new instances from your container on each call, your container is acting like a simple factory, not as a service container/dependency injection container.
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/2c879363-54ca-4723-8a6e-01c1c9917718%40googlegroups.com.
> Basically this is the text :
>
> Two successive calls to get with the same identifier SHOULD return the same
> value. However, depending on the implementor design and/or user
> configuration, different values might be returned, so user SHOULD NOT rely
> on getting the same value on 2 successive calls.
>
> I don't want to drag everyone again to the same discussion. But I wonder if
> there is any implementors having any concern about the same.
Just like @mwop, I've never had an issue with this behaviour.
Actually, I'd be interested in knowing what is your concern with this? Do you have an actual use case in mind that absolutely requires the container to always return the same value for all entries?
We can of course work on standardizing the notion of "factories" like described here (https://github.com/container-interop/container-interop/issues/44) but this is IMHO a whole different PSR as factories may/should not be containers.
You can argue to create wrappers or do in the configuration level. But for a specification it should be very clear what it returns as Pedro Cordeiro mentioned in this thread.
Always returns new instance
or
You will always get the same object.
We can of course work on standardizing the notion of "factories" like described here (https://github.com/container-interop/container-interop/issues/44) but this is IMHO a whole different PSR as factories may/should not be containers.
I don't think it need to be a different PSR itself for every containers have the functionality for the same. Either in configuration or having a different method. So why not suggest a method itself ?
I understand that the object creation inside Factory can be using "new" keyword than using the container itself ie why you suggested a different PSR. You can create a different PSR for sure.
So in that case as in discussion https://github.com/container-interop/container-interop/issues/69#issuecomment-251316682 it will be something like
class SomeContainer implements ContainerInterface, FactoryInterface {}
Now your container's get can return new or shared instance depending on configuration and make / create can create new instances.
Didn't we removed the configuration level of container to return shared / new instances if we say "get" always return same instance and "make / create" always create new instance ?
As this discussion started 2 days before and none of the existing FIG 3.0 members have the problem may be this is only concern for me. We can wrap this up if there is no further issues raised.
Small point: should the has() section in 1.1 say that the entry identifier MUST be a string, similar to how it does so for get()?
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+unsubscribe@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/CAJp_myX6QenJQtgmkDYRmJp6ffEaCfO3gDDKHOur1Sq4biLWRw%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.