2017-25 © Pedro Peláez
 

library bitframe-fastroute

FastRoute router middleware for BitFrame microframework

image

designcise/bitframe-fastroute

FastRoute router middleware for BitFrame microframework

  • Sunday, July 22, 2018
  • by designcise
  • Repository
  • 1 Watchers
  • 0 Stars
  • 45 Installations
  • PHP
  • 0 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 150 % Grown

The README.md

BitFrame\FastRoute

CI Maintainability Test Coverage, (*1)

FastRoute wrapper class to manage http routes as a middleware., (*2)

Installation

Install using composer:, (*3)

$ composer require designcise/bitframe-fastroute

Please note that this package requires PHP 8.2.0 or newer., (*4)

Examples

Using Attributes for Route Declaration

class SomeController
{
    #[Route(['GET'], '/hello/123')]
    public function indexAction(
        ServerRequestInterface $request,
        RequestHandlerInterface $handler,
    ): ResponseInterface {
        $response = $handler->handle($request);
        $response->getBody()->write(
            "BitFramePHP - 👋 Build Something Amazing Today!"
        );

        return $response;
    }
}
use BitFrame\App;
use BitFrame\Emitter\SapiEmitter;
use BitFrame\FastRoute\Router;
use SomeController;

require 'vendor/autoload.php';

$app = new App();
$router = new Router();

$router->registerControllers([
    new SomeController(),
]);

$app->run([
    SapiEmitter::class,
    $router,
    // ...
]);

Using Inline Callback to Handle Route

use BitFrame\App;
use BitFrame\Emitter\SapiEmitter;
use BitFrame\FastRoute\Router;

require 'vendor/autoload.php';

$app = new App();
$router = new Router();

$router->map(['GET', 'POST'], '/test', function ($request, $handler) {
    $response = $handler->handle($request);
    $response->getBody()->write('Test Page');
    return $response;
});

$app->run([
    SapiEmitter::class,
    $router,
    // ...
]);

Tests

To run the tests you can use the following commands:, (*5)

Command Type
composer test PHPUnit tests
composer style CodeSniffer
composer md MessDetector
composer check PHPStan

Contributing

  • File issues at https://github.com/designcise/bitframe-fastroute/issues
  • Issue patches to https://github.com/designcise/bitframe-fastroute/pulls

License

Please see License File for licensing information., (*6)

The Versions

22/07 2018

dev-master

9999999-dev

FastRoute router middleware for BitFrame microframework

  Sources   Download

MIT

The Requires

 

The Development Requires

22/07 2018

1.0.4

1.0.4.0

FastRoute router middleware for BitFrame microframework

  Sources   Download

MIT

The Requires

 

The Development Requires

30/06 2018

1.0.3

1.0.3.0

FastRoute router middleware for BitFrame microframework

  Sources   Download

MIT

The Requires

 

The Development Requires

29/06 2018

1.0.2

1.0.2.0

FastRoute router middleware for BitFrame microframework

  Sources   Download

MIT

The Requires

 

The Development Requires

18/05 2018

1.0.1

1.0.1.0

FastRoute router middleware for BitFrame microframework

  Sources   Download

MIT

The Requires

 

The Development Requires

16/05 2018

1.0.0

1.0.0.0

FastRoute router middleware for BitFrame microframework

  Sources   Download

MIT

The Requires

 

The Development Requires