This example shows how you can easily load controllers by convention with silex. The following routes are all valid:
- /
- /index
- /index/index
- /foo
- /foo/index
- /foo/hello
- /foo/hello?name=igorw
A possible extension to this would be passing the application to the controller as well, either to the constructor of the class, or to the method directly. Or using some kind of mapping (possibly with annotations) to inject specific services only.
Hi,
I was looking for controller based routing for silex, then foudn some providers but I also wanted to have the service container directly injected into my controllers, so with this snippet I could implement such a provider, I hope it's working fine and I'm wondering if you guys can check it and improve it
https://github.com/AchrafSoltani/RoutingServiceProvider
Best Regards