include '../src/Router.php'; // application dependencies include 'App/ProductsController.php'; include 'App/DB/ProductsRepository.php'; use Objectiveweb\Router; $app = new Router(); // app configuration $app->addRule('App\\DB\\ProductsRepository', ['shared' => true, 'constructParams' => [array(array('name' => "Cassete Recorder", 'sku' => 1, 'price' => 100.0), array('name' => "Tractor Beam", 'sku' => 2, 'price' => 7.99))]]); $app->GET("/", function () { return <<<EOF <html> <body> <h1>Router Example page</h1> <h2>ProductsController</h2> <ul> <li><a href="index.php/products">Index: Products listing (json)</a></li> <li><a href="index.php/products/1">Path variable: Product detail</a></li> <li><a href="index.php/products/sale">Custom method: Products with 10% discount</a></li> <li><a href="index.php/products/sale/50">Custom method with path parameters: Products with 50% discount</a></li> <li><a href="index.php/products/anything/really?error=1">before(): Check error trigger</a></li> EOF; }); /** * Router::controller will bind a path to a class, using the following schema * * GET / => $controller->index(); * POST / => $controller->post($decoded_post_body); * PUT / => $controller->put($decoded_post_body); * PATCH / => $controller->patch($decoded_post_body); *