Ejemplo n.º 1
0
<?php

require "RestRecipes/autoload.php";
use RestRecipes\Router;
$app = new Router();
$app->route("/order/<id>", "PUT", function ($order_id, $data) {
    echo $order_id;
    echo "\n" . $data;
});
Ejemplo n.º 2
0
<?php

require_once "RestRecipes/autoload.php";
use RestRecipes\Router;
$app = new Router();
$app->route("/recipe/", "GET", function () {
});
$app->route("/recipe/create", "POST", function ($data) {
});
$app->route("/recipe/create/<name>", "POST", function ($name, $data) {
});
$app->route("/recipe/<id>", "GET", function () {
});
$app->route("/recipe/<id>", "PUT", function ($data) {
});
$app->route("/recipe/<id>", "DELETE", function () {
});
$app->route("/recipe/<id>/export", "GET", function () {
});
$app->route("/recipe/<id>/<someVar>", "GET", function () {
});
/* Complex stuff */
function someFunc()
{
    if (func_num_args > 0) {
        // Do stuff with $name
        return;
    }
    echo "Some Content\n";
    return;
}