Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
kawanamiyuu committed Jul 9, 2020
1 parent c3685fd commit a4fc9a6
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
# K9u.Framework

[![badge](https://github.com/kawanamiyuu/K9u.Framework/workflows/CI/badge.svg)](https://github.com/kawanamiyuu/K9u.Framework/actions?query=workflow%3ACI)

```php
use Acme\BarMiddleware;
use Acme\BuzRequestHandler;
use Acme\FooMiddleware;
use K9u\Framework\ApplicationInterface;
use K9u\Framework\FrameworkModule;
use Laminas\Diactoros\ServerRequestFactory;
use Ray\Compiler\ScriptInjector;
use Ray\Di\Bind;
use Ray\Di\InjectorInterface;

$module = new FrameworkModule([
FooMiddleware::class,
BarMiddleware::class,
BuzRequestHandler::class,
]);

$injector = new ScriptInjector('/path/to/cache', function () use (&$injector, $module) {
(new Bind($module->getContainer(), InjectorInterface::class))->toInstance($injector);
return $module;
});

$app = $injector->getInstance(ApplicationInterface::class);
assert($app instanceof ApplicationInterface);

$request = ServerRequestFactory::fromGlobals();

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

0 comments on commit a4fc9a6

Please sign in to comment.