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 theregister
function inlib/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(); if ($route == $bones->route && !static:: $route_found && $bones->method == $method) { static::$route_found = true; echo $callback($bones); } else { return false; } }