2015年2月18日星期三

Rob Allen: Routing to a controller with Slim


Rob Allen has a new post today sharing an extension for Slim he's written to make working with controllers easier.



In a couple of projects that I've written using Slim Framework, I've found it beneficial to organise my code into controllers with injected dependencies; probably because that's how I'm used to working with ZF2. To make this easier, I've written an extension to the main Slim class and packaged it into rka-slim-controller which will dynamically instantiate controllers for you for each route.


His library makes it easy to define controller "paths" instead of the typical closures Slim requires to direct the request to a controller file. He gives several example routes, the code that the controller needs and shows how you can inject objects into the constructor of the controller (dependency injection).


Link: http://akrabat.com/slim-framework/routing-to-a-controller-with-slim-framework/

没有评论:

发表评论