We are thrilled to inform you that Lancecourse is becoming INIT Academy — this aligns our name with our next goals — Read more.

It seems like you are using an ad blocker. To enhance your experience and support our website, please consider:

  1. Signing in to disable ads on our site.
  2. Sign up if you don't have an account yet.
  3. Or, disable your ad blocker by doing this:
    • Click on the ad blocker icon in your browser's toolbar.
    • Select "Pause on this site" or a similar option for lancecourse.com.

Laravel for Tortoises - part 4: Routing

By zooboole 9 years ago
A route is **a path or a way** to get from one place to another. It's actually the path through which an information flows. So, routing is the principle in which decisions are made on how an information takes or goes through a specific path in a given system. This part discusses anything Laravel routing.

3 Comments

Sign in to reply

andy
andy
9 years ago Reply
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
zooboole
9 years ago Reply
Oh wow I am really surprised I just saw your comment. Thanks **@captain sensible** for this plus.
zooboole
zooboole
2 days ago Reply
Thanks