As someone who finds ContainerIterface very useful, I'd like to respond to 
Nicolas' question:

What "id" should the router "get()"?


The router should "get()" the "id" which is configured for the current 
route.

At least this is what I do in my application framework with FastRoute:

- User configures actions as callables in the router 
(https://github.com/woohoolabs/harmony#define-your-routes)
- Router finds the current route and stores the appropriate callable
- Dispatcher fetches the previous callable by which it instantiates a 
controller (if possible) then invokes the action 
(https://github.com/woohoolabs/harmony/blob/master/src/Middleware/DispatcherMiddleware.php#L49)

Without ContainerInterface, I should have used an Adapter (e.g. the 
Acclimate package) or I could have hardwired a specific container into my 
framework to achieve so (I would have hated both solutions).

I know that you don't like the fact that Container "id"-s can't be really 
reckoned upon, but in many cases (like in my example) it is possible to 
"shift the responsibility" to the end-user to supply the appropriate "id"-s 
for the container so that containers don't have to know anything about the 
"id"-s.

I find PSR-11 fascinating because it is a very simple and elegant common 
ground for use-cases where knowing the "id"-s by the container is not 
needed. My libraries are very simplicistic so maybe that's why they usually 
fall in this category. I can admit however that it is very likely that this 
is not always the case: then PSR-11 is truly not very useful for those 
projects. But I do think that the majority of libraries will hugely profit 
from PSR-11 because they can become loosely coupled with containers - but 
yet easily connected to them.

Cheers,

Máté

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/3780d606-cf05-4670-a97a-31058640cbcc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to