In my company most of our projects we have been using custom-zend framework and I love their routing concepts. It gives you various options of handling many different routes to get the data based on your needs – just amazing.
Let me get straight with the topic. With Zend Framework, it is easy to route your URL in a nice way without having an head-ache of working with .HTACCESS file. Thanks a bunch.
Most of us know how to route an URL with routes.ini, for example:
routes.contact.route = “contact-us”routes.contact.defaults.module = “contact”routes.contact.defaults.controller = “contact”routes.contact.defaults.action = “index”– this will route a URL http://example.com/contact-us into “contact” module >> “ContactController.php” controller >> “indexAction()” action.
What’s the big deal? We know this, yes I agree, have you tried routing a domain?.. 😉 Most of us may not, definitely I have not it does not stop there yet, Zend Framework also gives you an option to route an URL based on host/domain name and that is cool!.
Yes it is, you can route a domain (hostname) too, see the example:
routes.contact.type = Zend_Controller_Router_Route_Hostname routes.contact.route = “contact.example.com” routes.contact.defaults.module = “contact” routes.contact.defaults.controller = “contact” routes.contact.defaults.action = “index” – this will route a domain http://contact.example.com/ to “Contact” module >> “Contact” controller >> “Index” action. – to get this working you have to specify the type of router in the type variable “Zend_Controller_Router_Route_Hostname“, by default zend framework will assign “Zend_Controller_Router_Route” to the type. – see the list of other route-type given by zend framework router.