PHP-Router icon indicating copy to clipboard operation
PHP-Router copied to clipboard

DI

Open cawa87 opened this issue 11 years ago • 8 comments

Hey, nice router. But it would be nice if it'll have and mechanism to inject some dependencies in controller\action.

cawa87 avatar Nov 07 '14 17:11 cawa87

@CawaKharkov It's a great ideia! have you thinking in anything?

malukenho avatar Nov 12 '14 10:11 malukenho

@malukenho I've modified router to inject service container.

cawa87 avatar Nov 12 '14 10:11 cawa87

And I think it would be nice, if user want to inject something to your controller you need to implement some interface InjectableInterface. And when calling dispatch inject container(or some service) to your controller.

cawa87 avatar Nov 12 '14 11:11 cawa87

@CawaKharkov can you open a PR please? :D

malukenho avatar Nov 12 '14 11:11 malukenho

@malukenho #45 PR

cawa87 avatar Nov 12 '14 12:11 cawa87

It would be cool to use as foundation. https://github.com/container-interop/container-interop

And nobody is forced to use a specific DI-Package.

mbunge avatar Oct 15 '15 07:10 mbunge

i think routing and DI are different concerns and should not be mixed...

mo-ba avatar May 30 '16 10:05 mo-ba

@mo-ba It's not about mix, It's about support.

malukenho avatar May 30 '16 11:05 malukenho