Last active
December 25, 2015 14:39
-
-
Save noodlehaus/fd2fc23f18acd448c57c to your computer and use it in GitHub Desktop.
aphpy concept
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 | |
// bootstrap file | |
use aphpy as app; | |
$blogs = app\load(__DIR__.'/fruits.php'); | |
$books = app\load(__DIR__.'/books.php'); | |
$v1 = app\prefix('v1', [ | |
'books' => $books, | |
'blogs' => $blogs | |
]); | |
$books[] = app\get('status', function () {}); | |
$v2 = app\prefix('v2-books', [ | |
'books' => $books | |
]); | |
serve($v1, $v2); |
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 | |
// routes for /blogs | |
use aphpy as app; | |
$routes = []; | |
// POST /blogs | |
$routes[] = app\post(function () { | |
}); | |
// GET /blogs | |
$routes[] = app\get(function () { | |
}); | |
// GET /blogs/<id> | |
$routes[] = app\get('<id>', function ($id) { | |
}); | |
// PUT /blogs/<id> | |
$routes[] = app\put('<id>', function ($id) { | |
}); | |
// DELETE /blogs/<id> | |
$routes[] = app\delete('<id>', function ($id) { | |
}); | |
return $routes; |
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 | |
// routes for /books | |
use aphpy as app; | |
$routes = []; | |
// POST /books | |
$routes[] = app\post(function () { | |
}); | |
// GET /books | |
$routes[] = app\get(function () { | |
}); | |
// GET /books/<id> | |
$routes[] = app\get('<id>', function ($id) { | |
}); | |
// PUT /books/<id> | |
$routes[] = app\put('<id>', function ($id) { | |
}); | |
// DELETE /books/<id> | |
$routes[] = app\delete('<id>', function ($id) { | |
}); | |
return $routes; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment