PSR-11 compatibility (container interface) #159
Replies: 6 comments 17 replies
-
I think this is the next logical step. A standard container can be a good foundation for future features. Whatever feature we build next can probably benefit from it. |
Beta Was this translation helpful? Give feedback.
-
Do it. Since it's not much overhead to add PSR-11 support, that definitely makes sense. The only downside could be that someone makes use of a 3rd party DI container that breaks with your non-blocking mantra. But since that is the choice of the user, that's not your problem ;) |
Beta Was this translation helpful? Give feedback.
-
PSR-11 compatibility is definitely on the longer-term(?) roadmap, so I can definitely see this coming at some point in time! 👍 When we publicly launched Framework X in November, there was a lot of feedback about lack of a DI container support, so we started implementing one with #92 and related tickets shortly thereafter. Ever since this implementation has landed, we haven't seen a lot of demand for other DI containers so far. I'm definitely open to the idea of implementing full PSR-11 support, but I'd love to see some actual demand for this before starting to work on features that happen to be "nice to have". For instance, what does "PSR-11 compatibility" really mean? I'm a big fan of standardization, but how are we planning to take advantage of this? Should our container implement PSR-11 WDYT? |
Beta Was this translation helpful? Give feedback.
-
Compatibility with PSR-11 would definitely be desirable - currently I do not see the option of interacting with the container, which is quite useful in certain cases. For example, I would like to bootstrap an entry from a container into the global helper. The second issue - currently I miss a lot of functionality known from other containers - tagging or partial autowiring with the replacement of just one element - something like PHP-DI - autowire () -> setConstructorParameter (...). Right now I have to resolve all entries and pass them myself into new instance. Until the X container will gain more popular features from other containers, it would be great to be able to switch to alternatives whenever needed. I would say that X container should implement ContainerInterface and if possible - app should accept other implementations. |
Beta Was this translation helpful? Give feedback.
-
Actually, the more I code with X, the more it is getting cumbersome with built in Container. Right now it works only in fully automatic way and only in request/response context. Let me show you few use cases which I find critical for an app development with X, and which are related to container. Global helpers.
Dictionary class is making a call to external api every 1 hour (loop interval) to load into memory some dictionaries I need pretty much all the time. Another use case could be some global functions to access app config class. As you can see, due to lack of something like $container->get() I built a workaround to fetch entries from container. Sadly, I had to use internal function which is probably not the most performant solution in this case and wrap it with fake request and make my class invokable. Testing External tools Internal tools |
Beta Was this translation helpful? Give feedback.
-
Good news, Framework X now supports the PSR-11 container interface to pass in custom containers! 🚀 Documentation: https://framework-x.org/docs/best-practices/controllers/#psr-11-container-interface |
Beta Was this translation helpful? Give feedback.
-
In addition to our new DI container (#92) back in December 2021 it would be a logical step to add full PSR-11 compatibility into Framework X. By standardizing the way entries are fetched from a container, Framework X can work with any compatible container.
What do you think about this? Looking for feedback to help prioritize feature ideas.
Beta Was this translation helpful? Give feedback.
All reactions