Closed codeguy closed 7 years ago
DIC should be required, imo
Why? You'll still be welcome to provide one, but there won't be one by default. One less dependency. Should also simplify the codebase.
feature propose : add a namespace by default ( by setting) like App\Controllers
$app->get('\','HomeController::index') ==> App\Controllers\HomeController
@kadevland You can add namespace App\Controllers
; to the top of routes.php
file and you can do that today in Slim 3.
I don't think it really would simplify it at all. Instead of accessing a service from the container we now need our own dependency management solution for Slim's services. The easiest way is singletons, or we end up with our own internal DIC... which raises the question of why bother.
These are the only 2 solutions that I can come up with, so perhaps there are more options that are better.
//cc @akrabat @codeguy @silentworks
@akrabat thx for this astuce
I think we should allow MyController::method
even without DIC. Otherwise we will be forcing users to add all controllers on the DIC (I'm not saying that this is a bad thing).
After further review, this is actually already in place EXCEPT for one change. We need to make the CallableResolver::__construct()
arguments optional.
Done
Because the DIC is optional, should we let router continue to resolve
MyController::method
route callables even if no DIC container is specified? Or should the DIC be required to use this callable format?/cc @akrabat