O'Reilly logo

CouchDB and PHP Web Development Beginner's Guide by Tim Juravich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — creating routes for us to test against Bones

Open up the index.php file and add the following two routes so that we can test our new code:

<?php
include 'lib/bones.php';
get('/', function($app) {
echo "Home";
});
get('/signup', function($app) {
echo "Signup!";
});


What just happened?

We just created two routes for our Bones class to handle / (which is the root URL) and /signup.

There are a few things to notice in the code that we just added:

  • Our two get routes are now clean, little functions, including our route and a function that will act as our callback function
  • Once the function is executed, we are using echo to display the simple text
  • When a route is matched and a callback is executed from Bones, the instance of Bones is returned ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required