amphp / injector

A recursive dependency injector used to bootstrap and wire together S.O.L.I.D., object-oriented PHP applications.
MIT License
31 stars 7 forks source link

unshare / reshare #17

Open leongrdic opened 2 years ago

leongrdic commented 2 years ago

I've been using auryn for a while now and literally just realized development has moved to this new repo. I've created a router library that actually depends on auryn and I'm using it in a few projects in production. You can find my router here: https://github.com/leven-framework/router (not very well documented yet) - auryn is used in the RouteHandler class

here's what I wanted to ask. what's the opinion on unsharing or resharing objects? I've followed an issue in the old repo (https://github.com/rdlowrey/auryn/issues/121) which kind of concluded that the option to share a different object of same class is a bug and will be prevented.

I haven't yet tested this new Injector but I'd like to point out that the ability to share an object of the same class again is very much useful in my router - for making a different MiddlewareCallback object available in each middleware of a route.

is there any chance this functionality could be supported officially?

thanks!

kelunik commented 2 years ago

This is something which will be supported by this new library, yes. I have similar use cases at work (though in Java), e.g. to connect to multiple databases.