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 — altering the register to support different methods

Now that we are retrieving the method on each request, we need to alter our register function so that we can pass $method along with each of our routes in order for them to match properly.

  1. Add $method onto the register function in lib/bones.php so that we can pass a method into the function:
    public static function register($route, $callback, $method) {
    
    $bones = static::get_instance();
    
  2. We now need to update our simple route matching in our register function to also check that the passed routes $method matches our instance variables $bones->method, which is the method that actually happened on the server:
    public static function register($route, $callback, $method) { $bones = static::get_instance(); ...

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