. Updated Daily. Editions SDA India   SDA Indonesia
JAX Asia 2008 - Conference for Enterprise Java, SOA, Spring, Web Services, Ajax, Agile and more
BUSINESS ENTERPRISE SOLUTIONS ARCHITECTURE INFORMATION SECURITY WIRELESS & MOBILITY DATA & STORAGE DEVELOPMENT HARDWARE













News

Tuesday, 17 April 2007

Learn URL Routing with PHP- Part 3

 

 

Doug Hill has published the final part of the series ‘URL routing with PHP’. In the final article, he builds a functional modular front controller that can be adapted to small projects. It is ‘C’ in Model View Controller (MVC) for a simple MVC Framework.

Doug in the first part of the series explores a simple procedural URL routing method that contains many of the disadvantages. In the second part of the series, he explains the basics that he covered in the first part.

He discusses the final part under the following heads:

A Few Changes

He says a few changes can be seen to the code that he had mentioned in the second part of the article. The Axial_URLInterpreter and the Axial_Command object received a few minor changes suggested via comments on the previous articles. Most of the changes are in the Axial_CommandDispatch class. A new class Axial_Controller is introduced in this article, along with some changes to the directory structure.

Dispatch Via Convention

He explains that using a front controller allows creation and access to controllers in a standard way. By using a consistent naming convention and directory structure, command objects can be dispatched via a generic piece of code. When a command is dispatched the appropriate controller is loaded and its execute() method called. He provides a code example to explain the concept.

The Controller

He instructs that all controllers must descend from the base class Axial_Controller. The execute() function in the base class searches for the function passed in the Axial_Command object prepended with a ‘_’ within the controller. If this method is found it is executed, if it is not found the _error() function is called. If no function is specified the _default() function is called. Here also he gives a code example to facilitate better understanding.

 

Read the Post

 

Related Reading: Learn About URL Routing with PHP

 

Related Reading: URL Routing with PHP- Part 2

 
 
print save email comment

print

save

email

comment

 
 

Search SDA Asia

Free eNewsletter

SDA Asia Magazine Free Download
 
 
 
Copyright @ 2008 SDA Asia Magazine - All Right Reserved Privacy Policy | Terms of Use