public function any_handler() { $this->template('any'); } // Add a custom header public function add_header() { echo '<h1>My custom header</h1>'; } // Output a template protected function template($template) { include dirname(__FILE__) . "/templates/{$template}.html"; } } // Create the instance $app = new Application(); // Run a before filter $app->before('get_info', 'add_header'); // Link up the urls $app->get('', 'get_index'); $app->get('info', 'get_info'); $app->get('json', 'get_json'); $app->get('xml', 'get_xml'); $app->get('redirect', 'get_redirect'); $app->get('page/<page>', 'get_page'); $app->any('any', 'any_handler'); $app->get('page/<page:\\d{4}>/<id>', 'get_page'); $app->get('page/<page:.*>', 'get_page'); // Run the application $app->run();