Documentation | Github | Installation

Exedra

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.

What's Exedra?

Nestful Routing
Write a routing beneath another route. Hierarchically design your application based on a nestable/groupable level of routing.
Route Oriented
From writing how your application may behave, to querying back the route for url generation, to hierarchically design your application, to binding your middleware on any node of your route.
Adaptive and flexible
Write and use your own handler, design your own routing component(s). Or customize your very own application structure.
Near-zero convention and configuration
There're still a configuration, and convention. But too little are required just to have your application running.
Fast
It's fast. Designed with minimum architecture in mind, without sacrificing the extensibility very much.
Contextual
Codes live in their context. Nothing is outworldy. No singletons, no facades.

Sneak peak

Convenient Routing [more]

$app->map->any('/books')->group(function($group) {
    $group->get('/')
    ->tag('bookList')
    ->execute(function() {
        // list books?
    });

    $group->get('/:id')
    ->execute(function() {
        // get single book?
    });
});
Annotated Route Controller [more]

/**
 * @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;
}
Middleware [more]

$app->map->middleware(function(Context $context) {
    return $context->next($context);
});
URL Generator [more]

// absolute route
echo $context->url->route('@person.list');

// search tagged route
echo $context->url->route('#bookList');
Service Registry [more]

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');
  });
Redirection [more]

// 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);
Path handling [more]

$file = $context->path->file('Logs/message.log');

// get contents
$contents = $file->getContents();

// put contents
$file->putContents('message from mars');
Session [more]

// 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');