Zaphpa = APIs for PHP

Intuitive, flexible & powerful API micro-router.

require_once('./vendor/autoload.php');
$router = new \Zaphpa\Router();

$router->attach('\Zaphpa\Middleware\AutoDocumentator', '/apidocs'); //auto-docs middleware
$router->attach('\Zaphpa\Middleware\MethodOverride');
$router->attach('\Zaphpa\CORS');

$router->addRoute(array(
  'path'  => '/users/{id}',
  'get'   => array('\MyAwesomeApp\UserController', 'getUser'),
  'post'   => array('\MyAwesomeApp\UserController', 'updateUser'),
));    
$router->route();

Makes building APIs in PHP easy & enjoyable.

Zaphpa, pronounced as the last name of Frank Zappa, is a routing microkernel inspired by Sinatra.rb, and implemented in PHP (hence the extra geeky "h" in the name creating the sub-pattern of: "php").

Zaphpa is a lightweight library that excels at single mission: free PHP API developers from the boilerplate of handling HTTP requests and implementing REST.

You can think of it as an equivalent of Sinatra (in Ruby) or Express.js (in Javascript) frameworks for PHP, if you will.

Who uses it?

Zaphpa is actively used by NPR's software teams in the Digital Media and Digital Services divisions, benefiting from thorough bug-fixing and various contributions by: @inadarei, @karoun, @randallsquared, @johnymonster, @jsgrosman and @d1b1.