You are viewing the website for BitFrame v1. BitFrame v2.0 was released on 11-May-2020 — new documentation and website will be available soon!

PHP Microframework

BitFrame is a highly customizable and event driven PSR-15 and PSR-7 compatible middleware microframework for PHP.

Get Started

Why BitFrame?

We felt that there was a dire need for a non-intrusive, standards-based PHP microframework that encourages the use of middleware-based services that plug right in with ease. This helps keep things well-organized, easy-to-manage and very simple.

Start Building In Minutes!

BitFrame has an easy learning curve with a very familiar feel — it's not rocket science!

Get Freedom Of Choice!

Don't be tied down to proprietary packages; use any PSR-7 or PSR-15 package you want (and it's super easy to plug them in).

Make It Your Own!

It's fully modular so you can customize, replace or extend every component as you please!

Lose The Extra Weight!

One of the driving goals of building BitFrame was to keep it free of unnecessary bloat — don't be the elephant in the room!

Scale Away To The Moon!

Having middleware dispatcher at its core makes scaling, debugging and upgrading hassle-free!

use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

require 'vendor/autoload.php';

$app = new \BitFrame\Application;

$app->run([
	\BitFrame\Message\DiactorosResponder::class,
	function (Request $request, Response $response, callable $next) {
		$response->getBody()->write('Hello World!');

		return $next($request, $response);
	}
]);
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

require 'vendor/autoload.php';

$app = new \BitFrame\Application([
    ResponseInterface::class => new \GuzzleHttp\Psr7\Response
]);

$app->run([
    \BitFrame\Message\DiactorosResponder::class,
	
	\BitFrame\Router\FastRouteRouter::class,
	new \Middlewares\AuraRouter(new \Aura\Router\RouterContainer)
]);
use \BitFrame\Factory\ApplicationFactory;
use \BitFrame\Factory\HttpMessageFactory;

ApplicationFactory::setEventManagerFactory(/* EventManagerFactoryInterface */);
ApplicationFactory::setDispatcherFactory(/* DispatcherFactoryInterface */);
ApplicationFactory::setRouteCollectionFactory(/* RouteCollectionFactoryInterface */);

HttpMessageFactory::setResponseFactory(/* ResponseFactoryInterface */);
HttpMessageFactory::setServerRequestFactory(/* ServerRequestFactoryInterface */);
HttpMessageFactory::setUriFactory(/* UriFactoryInterface */);
HttpMessageFactory::setStreamFactory(/* StreamFactoryInterface */);
require 'vendor/autoload.php';

$app = new \BitFrame\Application;

$app->get('/hello/{name}', function ($request, $response, $next) {
    $name = $request->getAttribute('name');
    $response->getBody()->write("Hello, $name");

    return $next($request, $response);
});

// have a strong foundation; create your middleware stack and only 
// use the services/middleware your app/api requires...
$app->run([
	\BitFrame\Message\DiactorosResponder::class,
	\BitFrame\ErrorHandler\WhoopsErrorHandler::class,
	\BitFrame\Router\FastRouteRouter::class
]);
require 'vendor/autoload.php';

$app = new \BitFrame\Application;

// add, remove, replace, debug or update individual services with ease
$app->run([
	\BitFrame\Message\DiactorosResponder::class,
	
	// remove an existing service
	\BitFrame\ErrorHandler\WhoopsErrorHandler::class,
	
	// add a new service at any time
	\Middlewares\Debugbar::class,
	
	// make changes to individual classes without affecting others
	\BitFrame\Router\FastRouteRouter::class
]);