PHP code example of designcise / bitframe-fastroute

1. Go to this page and download the library: Download designcise/bitframe-fastroute library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

designcise / bitframe-fastroute example snippets


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;

;

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

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

function ($request, $handler) {
    $response = $handler->handle($request);
    $response->getBody()->write('Test Page');
    return $response;
});

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