echo "You won't see this..."; $app->pass(); }); $app->get('/hello/:name', function ($name) use ($app) { echo "But you will see this!"; }); 13年10月5⽇日星期六
use ($app) { echo "Hello $name"; })->name('hello'); //Generate a URL for the named route $url = $app->urlFor('hello', array('name' => 'Josh')); --> /hello/Josh 13年10月5⽇日星期六
$app->get('/books/:id', function ($id) use ($app) { // Get book with ID }); $app->post('/books/:id', function ($id) use ($app) { // Create book with ID }); $app->put('/books/:id', function ($id) use ($app) { // Update book with ID }); $app->delete('/books/:id', function ($id) use ($app) { // Delete book with ID }); 13年10月5⽇日星期六
($app) { $app->get('/oauth', function () use ($app) { // facebook oauth }); $app->get('/getAlbum', function () use ($app) { // Get facebook albums }); $app->get('/getPhotos/:album_id', function ($album_id) use ($app) { // Get facebook photos by album }); }); 13年10月5⽇日星期六
mware2() { echo ‘This is middleware2 ’; } $app->get(‘/hello’, ‘mware1’, ‘mware2’, function() use ($app) { echo ‘hello everyone!!’; } output --> This is middleware1 This is middleware2 hello everyone!! 13年10月5⽇日星期六
//Do something }); // after output buffering turn off and after the Response is sent $app->hook('slim.after', function () { //Do something }); 13年10月5⽇日星期六
is dispatched $app->hook('slim.before.router', function () { //Do something }); // after the router is dispatched, before the Response is sent $app->hook('slim.after.router', function () { //Do something }); 13年10月5⽇日星期六
() { //Do something }); // after the current matching route is dispatched $app->hook('slim.after.dispatch', function () { //Do something }); 13年10月5⽇日星期六
priority --> it will sort all callables assigned to it by priority (ascending) $app->get(‘/json_callback’, function() use ($app) { $app->applyHook('json.dispatch'); }); 13年10月5⽇日星期六