get('/', function (Application $app) { return $app->redirect(BACKBONE); }); $app->get('/server', function (Application $app) { return $app->redirect(BACKBONE); }); $app->get('/todos/{id}', function (Application $app, int $id) { /** @var \Model $model */ $model = $app['model']; $todos = $model->load(); $todo = $todos[$id] ?? NULL; return $app->json($todo); }); $app->put('/todos/{id}', function (Application $app, Request $request, int $id) { /** @var \Model $model */ $model = $app['model']; $data = json_decode($request->getContent(), true); $created = $model->save($data); return new Response('Saved', $created ? Response::HTTP_CREATED : Response::HTTP_OK); }); $app->match('{url}', function ($url) { var_dump($url); });