bapao/bapao

This package is abandoned and no longer maintained. No replacement package was suggested.

Tiny agnostic PSR-7 middleware micro framework

Installs: 119

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Type:framework

v0.1.5 2016-08-29 16:58 UTC

This package is not auto-updated.

Last update: 2016-09-17 10:05:38 UTC


README

Build Status Scrutinizer Code Quality Code Coverage

Tiny agnostic PSR-7 middleware micro framework.

Installation

Install Bapao via Composer:

$ composer require bapao/bapao

About

Bapao does not force you to use a specific DI container, routing or middleware package. At initialization of the Bapao application you can inject the DI container of your choice. Thereby the following services must be present in the container:

Service Interface
request Psr\Http\Message\ServerRequestInterface
response Psr\Http\Message\ResponseInterface
response.emitter Bapao\Bapao\Interfaces\ResponseEmitterInterface
middleware.dispatcher Bapao\Bapao\Interfaces\MiddlewareDispatcherInterface
router n.a.
router.middleware PSR-7 middleware compliant

An example service provider based on The PHP League DI container is available for Bapao: League Container Provider. This service provider contains the following packages:

Simple example

Create a front controller (for instance index.php) and add:

require_once __DIR__.'/vendor/autoload.php';

use Bapao\Bapao\Application;
use Bapao\LeagueContainerProvider\LeagueContainerProvider;
use League\Container\Container;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;

// create a DI container of your choice, based on container-interop
$container = new Container();
$container->addServiceProvider(new LeagueContainerProvider());
// add more service providers...

// init Bapao application
$app = new Application($container);

// add middleware
// $app->addMiddleware(new SomeExampleMiddleware());

// add routing rules with router of your choice
$router = $app->getRouter();
$router->get('/', function (Request $request, Response $response, array $arguments) {
  $response->getBody()->write('Welcome to Bapao!');
  return $response;
});

// run Bapao
$app->run();

Service providers

Bapao relies heavily on service providers. The following service providers are available:

Middleware

Bapao's internals are handled by PSR-7 based middleware. Bapao route handling is in fact the last of a given set middleware.

$app->addMiddleware(new ExampleMiddleware);

Oscarotero/Psr7Middlewares has a extended set of various middleware classes available.

Test

Run tests via phpunit:

$ php vendor/bin/phpunit

Side note

Bapao does not aim to compete with the well-known micro frameworks such as Slim, Silex and Lumen. They are great and well documented. Bapao is more or less an experiment to combine great PHP packages into a tiny wrapper framework.

License

Bapao is licensed under the MIT license.