PHP code example of k9u / framework

1. Go to this page and download the library: Download k9u/framework 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/ */

    

k9u / framework example snippets


use K9u\Framework\ApplicationInterface;
use K9u\Framework\CachedInjectorFactory;
use K9u\Framework\Demo\FakeMiddleware;
use K9u\Framework\Demo\FakeRequestHandler;
use K9u\Framework\FrameworkModule;
use Laminas\Diactoros\ServerRequestFactory;
use Ray\Di\AbstractModule;

class AppModule extends AbstractModule
{
    protected function configure()
    {
        $middlewares = [
            FakeMiddleware::class,
            FakeRequestHandler::class
        ];

        $this->install(new FrameworkModule($middlewares));
    }
}

$module = new AppModule();
$injector = (new CachedInjectorFactory('/path/to/cache'))($module);

$app = $injector->getInstance(ApplicationInterface::class);
/* @var ApplicationInterface $app */

$request = ServerRequestFactory::fromGlobals();

$app($request); // handle request and emit response