A nestful route oriented PHP microframework, shipped with a flexibility that allow you to design, plan and prototype your application and execution hierarchically through the map of routing.
$app->map->any('/books')->group(function($group) {
$group->get('/')
->tag('bookList')
->execute(function() {
// list books?
});
$group->get('/:id')
->execute(function() {
// get single book?
});
});
/**
* @name about-us
* @path /about-us
* @method GET|POST
*/
public function executeAboutUs(Context $context)
{
return 'This is about page';
}
/**
* @name auth
* @path /auth
*/
public function groupAuth()
{
return AuthController::class;
}
$app->map->middleware(function(Context $context) {
return $context->next($context);
});
// absolute route
echo $context->url->route('@person.list');
// search tagged route
echo $context->url->route('#bookList');
use Exedra\Application;
use Twig\Loader\FilesystemLoader;
use Twig\Environment;
// some codes..
$app->set('@twig', function(Application $app) {
$viewPath = $app->path->to('views');
$loader = new FilesystemLoader($viewPath);
return new Environment($loader);
});
// usage example
$app->map->any('/contact-us')
->execute(function(Context $context) {
return $context->twig->render('contact.twig');
});
// redirect with absolute route
return $context->redirect->route('@person.list');
// redirect to tagged route
return $context->redirect->route('#bookList');
// redirect to url
return $context->redirect->url($url);
$file = $context->path->file('Logs/message.log');
// get contents
$contents = $file->getContents();
// put contents
$file->putContents('message from mars');
// dot notation based session
$context->session->set('facebook.token', $token);
$context->session->set('facebook.perms', $perms);
// array of token, permissions
$facebookData = $context->session->get('facebook');
// delete array of 'facebook' session data
$context->session->destroy('facebook');