Laravel for Tortoises - part 4: Routing

captain sensible Since Dec 18, 2015 3 Posts

Interesting series of tutorials on larval. Couple of things maybe should should mention:

All PHP users know that PHP is server side and therefore usually expect that anything PHP has to go into the ROOT or sub-directory of a web server; so users are expecting laravel will go into something like /opt/lampp/htdocs for xampp on lInux. This is the case for codeigniter & fatfree; actually if your on Linux this can be a real pain since as a normal user you don't have write access to edit anything; so it means messing around with adding yourself to a sudoers list(no we don't all use Ubuntu) or adding yourself to the apache group.

Since Laravel ships with its own server you create a project somewhere in your home directory; as mentioned in these tutorials , you cd to your project folder and start the server up with : $ php artisan serve then in your browser address bar type in ; http://localhost:8000 to see your project landing page.

On views using something like Route::get('/about',function(){ return view ('about'); });

in routes.php so that you can see a page called about from your url http://localhost:8000/about isn't that exciting since anybody can do that without a framework. What would be more interesting would be to show how you can chain load a head & footer for every page so that even if say you have 250 pages you still use a single head.blade.php & foooter.blade.php for any content page loaded. eg in fatfree its done like: $f3->route('GET /', function($f3) {

    $view = new View;
$f3->set('title', 'home page');
    echo $view->render("views/header.php");
echo $view->render("views/newmenu.php");
echo $view->render("views/home.php");
echo $view->render("views/footer.php");


zooboole Since Jan 22, 2015 112 Posts

Oh wow I am really surprised I just saw your comment. Thanks @captain sensible for this plus.