Closed gusrub closed 8 years ago
I'm just going to answer my own silly question, thing is, that middleware runs on the opposite order that I thought so I was adding the config middleware to the container before adding the one for the database but it must be the other way around because of the order of the callables.
Reading the documentation on middleware helped me understood this.
Hi @gusrub, it's nice to know that you were able to solve the problem. Thank you for sharing your solution. :+1: I'm closing this issue.
I'm just going to answer my own silly question, thing is, that middleware runs on the opposite order that I thought so I was adding the config middleware to the container before adding the one for the database but it must be the other way around because of the order of the callables.
Reading the documentation on middleware helped me understood this.
I love you, man)))))))
This is more of a question than anything. As I read on the documentation there are two possible ways to load the configuration values:
However, how can I load the configuration within a callable for a middleware? take the following code:
In the example above I'm adding the
db
instance so I can do queries within my routes, however, the configuration instance is not available at that point, so if I do this:It won't work because
$config
is null (or the return value ofgetConfig()
for that matter). Is there a way to make that work? Maybe I'm missing something or I still don't completely understand the order of execution in the middleware/container.Thanks in advance!