radiate-framework / framework

A WordPress plugin and theme framework
https://radiate-framework.github.io/
MIT License
4 stars 0 forks source link

Use dependency injection for controllers #22

Closed BenRutlandWeb closed 3 years ago

BenRutlandWeb commented 3 years ago

Is your feature request related to a problem? Please describe. Currently I can only access the $request and $id parameter from the controller methods.

Describe the solution you'd like I'd like the controller methods to be resolved from the container so I can type hint my dependencies.

Describe alternatives you've considered Getting dependencies from within the controller using the facades but it would be neater to inject automatically.

Additional context REST uri params should be type hinted by their name e.g.


// require params
Route::get('/create-file', function(Filesystem $files) {
  //
});
// require params
Route::get('/user/{user_id}/create', function(int $user_id) {
  //
});
// and optional params
Route::get('/user/{name?}', function(string $name = 'no name') {
  //
});