[ 'date' => '2011-03-29', 'author' => 'igorw', 'title' => 'Using Silex', 'body' => '...It takes time on version changes...', ], 2 => [ 'date' => '2015-03-29', 'author' => 'igorw', 'title' => 'Using Silex 2', 'body' => '...Especialy S1 to S2...', ], ]; // Default: http://blog, not http://blog/ public function fifiAction(Application $app, $id) { return "

Fifi action {$id}

\n"; } public function index() { $output = "\n"; return $output; } // Default: http://blog, not http://blog/ public function show(Application $app, $id) { if (!isset (static::POSTS[$id])) { // Will trigger the error() (or built-in) error handler.1 $app->abort(Response::HTTP_NOT_FOUND, "Post $id does not exist."); } $post = static::POSTS[$id]; return "

{$post['title']}

" . "

{$post['body']}

"; } // Encode response manually. public function json(Application $app) { return $app->json(static::POSTS); } // Rely on the view handler. public function jsonView() { return static::POSTS; } }