Created
June 19, 2016 22:02
-
-
Save eimihar/99e0fa70aa12a73752c121f80dc33672 to your computer and use it in GitHub Desktop.
A code sample for youtube v=LrfbmIYAGWI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
GET /api/articles | |
POST /api/articles | |
GET /api/articles/:article-id | |
PUT /api/articles/:article-id | |
GET /api/articles/:article-id/author | |
GET /api/shops | |
GET /api/shops/:shop-id | |
GET /api/shops/:shop-id/products | |
*/ | |
require_once __DIR__.'/vendor/autoload.php'; | |
$app = new \Exedra\Application(__DIR__); | |
$app->map->any('/api')->group(function($api) | |
{ | |
$api->any('/articles')->group(function($articles) | |
{ | |
$articles->get('/')->execute(function() | |
{ | |
//.. list some articles here. | |
}); | |
$articles->post('/')->execute(function() | |
{ | |
//.. create an article | |
}); | |
$articles->any('/[:article-id]')->group(function($article) | |
{ | |
$article->get('/')->execute(function() | |
{ | |
//.. get an article | |
}); | |
$article->put('/')->execute(function() | |
{ | |
//.. update an article | |
}); | |
$article->get('/author')->execute(function() | |
{ | |
}); | |
}); | |
}); | |
// it'll look for the routes under {root}/app/Routes | |
$api->any('/shops')->group('api.shops.php'); | |
}); | |
// a collection of commands, basically. | |
$app->wizard($argv); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment