News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Dave Marshall:
Silex Controllers as Services
October 03, 2012 @ 09:36:15

Dave Marshall has written up a post about how he uses Silex controllers as services that allow him to define his controller methods in separate classes with a custom resolver.

There's currently a pull request in the queue for Silex that adds a cookbook entry for using controller classes, but I wanted to take it a step further and have my controllers as services, much like what's possible with the full symfony framework (See Richard Miller's post for further reading).

He includes some example code showing the creation of the Silex application with a service definition, the custom "ControllerResolver" to override the default and a simple controller class ("PostController") that just returns a JSON response. You can find the full example code for it on github.

0 comments voice your opinion now!
silex controller service resolver class tutorial microframework


blog comments powered by Disqus

Similar Posts

Kevin van Zonneveld's Blog: Convert anything to Tree Structures in PHP

SitePoint PHP Blog: HHVM and Hack - Can We Expect Them to Replace PHP?

Tom Oram's Blog: Unit testing a Zend Framework 2 Controller

PHP-GTK Community Site: Accessing geo-nick with Zend Framework (Zend_XmlRpc_Client)

SitePoint PHP Blog: Command line PHP using Symfony Console


Community Events

Don't see your event here?
Let us know!


interview conference release framework configure introduction api example php7 community application opinion library performance symfony2 laravel language voicesoftheelephpant series podcast

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework