Skip to content

Instantly share code, notes, and snippets.

@noodlehaus
Last active December 25, 2015 14:39
Show Gist options
  • Save noodlehaus/fd2fc23f18acd448c57c to your computer and use it in GitHub Desktop.
Save noodlehaus/fd2fc23f18acd448c57c to your computer and use it in GitHub Desktop.
aphpy concept
<?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);
<?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;
<?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