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

Adding support for complex routing

Our framework is technically all ready for us to start building on top. However, we don't have enough support to match and handle complex routes. Since most applications will need this, let's quickly add it.

Handling complex routes

For example, in the index.php file, we'll want to be able to define a route for a user profile. This route might be /user/:username. In this case, :username will be a variable that we can then access. So, if you went to the URL /user/tim, you could access the username tim by using Bones to grab that section of the URL, and return its value.

Let's start by adding another variable and another call in our __construct function to our lib/bones.php file:

public $content = ''; public $vars ...

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