During my "Lets Code" live stream last night I had a little issue dealing with the dependency chain between
Flash/Session and its required
Session adapter. That said the issue was I was trying to register
Flash/Session's DI container without an existing
Session adapter to inject into it. You can see what I am talking about here at the specific point in my video:
Under further inspection of
Flash/Session I noticed that in this instance
Flash/Session calls out to DI to get a shared copy of the
Session dependency but does not seem to return any kind of logging or error message in the event that the dependency cannot be met. https://github.com/phalcon/cphalcon/blob/107b6f0197b0464d9f6b11ff390a560c000bf448/phalcon/flash/session.zep#L39-L44
I dug a little deeper into
DI and found:
Which definitley shows an error message could be raised through an execption as a possibility but
public function get(string! name, parameters = null) also acts as a builder in the case that the dependency has not been registered. This leads me to the assumption that either this fallback builder isn't working or it has created a new session adapter on each request leaving me unable to share my state over a persistent session.
Ultimately, I would be happy to create a PR for this issue but I wanted to make sure I was observing a design "oversight" and not my own ignorance.
Provide feedback to PHP error logger when a fallback dependency container is created as a warning with a link to the documentation for that service. For DI dependencies that require explicit shared state it should somehow be enforced.
Let me know what you all think and I will get to work.
My Phalcon Init from the video