The Laravel PHP Framework: A Walkthrough

Posted 5th August 2011

Lar­avel is the new kid on the block of PHP frame­works, and whilst in its early stages of evo­lu­tion (the author wrote it, he says, in the early part of 2011) it does promise — and deliv­ers, from what I can tell — an expres­sive syn­tax and an ele­gant (indeed, you might say elo­quent) ORM. Lar­avel is a fully Object Ori­ented MVC frame­work which makes exten­sive use of fea­tures new or recent to PHP — you can for­get about run­ning it on PHP4. With PHP5.3 com­pli­ant name­spacing mech­a­nisms as opposed to, for exam­ple, Zend Framework’s pseudo-​namespacing, it’s cer­tainly what you might call a mod­ern framework.

Routes

In Lar­avel you define routes — which, stay­ing true to the REST­ful par­a­digm, are defined not just as URI’s, but accord­ing to the HTTP oper­a­tion they are to react to. Thus, instead of defin­ing a route such as /about-us you would define a func­tion to respond to a GET request on that URI, which is done using a clo­sure which looks reas­sur­ingly like JavaScript: