PHP PSR-15 / PSR-7 middleware dispatcher microframework

1.1.5 2018-10-13 21:47 UTC


  • Highly customizable and event driven PSR-15 and PSR-7 compatible middleware microframework for PHP;
  • Simple to learn, use and implement;
  • Follows the PSR standards and integrates the best of existing opensource frameworks wherever possible.

Why use BitFrame?

BitFrame's approach of making the middleware dispatcher the core component of the framework encourages the developer to use middleware-based services that plug right-in with ease. This allows for greater flexibility especially in terms of debugging, replacements and updating. While this design pattern may not suit the needs of all projects, it certainly has its advantages for long-term and strategic ones because as they grow in complexity the underlying framework helps keep things well-organized, easy-to-manage and very simple.

At the core of our development, we've tried very hard to abide by some simple rules that we've mostly found missing in other microframeworks:

  1. Be well-documented and intuitive;
  2. Facilitate the developer and be nonintrusive;
  3. Be free of unnecessary bloat;
  4. Promote modularity to allow any component of the framework to be easily replaced;
  5. Provide the flexibility of using existing PSR-15 / PSR-7 middlewares that plug right in easily;
  6. Provide the ability to share variables and application data seamlessly across all the middlewares.


Install BitFrame and its required dependencies using composer:

$ composer require designcise/bitframe

Please note that BitFrame requires PHP 7.1.0 or newer.


After you have installed the required dependencies specific to your project, create an .htaccess file with at least the following code:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

This sets the directive in apache to redirect all Http Requests to index.php in which we can write our application code. For example:


require 'vendor/autoload.php';

$app = new \BitFrame\Application();

    function ($request, $response, $next) {
        $response->getBody()->write('Hello World!');

        return $next($request, $response);


From the code above you can see that we're using two middlewares:

  1. A PSR-15 based wrapper of Zend Diactoros that allows us to emit the HTTP Response to the requesting user-agent (such as a web browser);
  2. A closure used to write Hello World! to the HTTP Response.

Similar to the \BitFrame\Message\DiactorosResponseEmitter middleware package we've developed some essential PSR-15 packages that are typically used in API and web app development. These can be added to BitFrame easily as per your project's need and are in no way a hard dependency.

Also note that, apart from these official packages, you can easily use any PSR-15 or PSR-7 based packages, or develop your own.

Refer to the official BitFrame documentation to learn more.


To execute the test suite, you will need PHPUnit.


Please see CONTRIBUTING for details.


Documentation is available at:


Please see License File for licensing information.