https://github.com/talesoft/tale-test-app
https://github.com/talesoft/tale-test-app
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/talesoft/tale-test-app
- Owner: Talesoft
- License: mit
- Created: 2016-02-29T23:24:32.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-01T00:44:04.000Z (over 10 years ago)
- Last Synced: 2025-03-04T15:48:10.798Z (over 1 year ago)
- Language: PHP
- Size: 3.91 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Tale Runtime
**A Tale Framework Component**
# What is Tale Runtime?
Tale Runtime is a small PSR-7 compliant, middleware-based HTTP runtime for any kind
of PHP project.
It acts as a foundation for web applications with PHP.
# Installation
Install via Composer
```bash
composer require "talesoft/tale-runtime:*"
composer install
```
# Usage
```php
$app = new Tale\Runtime\App();
class HelloMiddleware implements Tale\Runtime\MiddlewareInterface
{
public function __invoke(
ServerRequestInterface $request,
ResponseInterface $response,
callable $next
)
{
$response->getBody()->write('Hello ');
return $next($request, $response);
}
}
class WorldMiddleware implements Tale\Runtime\MiddlewareInterface
{
public function __invoke(
ServerRequestInterface $request,
ResponseInterface $response,
callable $next
)
{
$response->getBody()->write('World!');
return $next($request, $response);
}
}
$app = $app->with(new HelloMiddleware())
->with(new WorldMiddleware());
Tale\Http\Emitter::emit($app->run()); //Outputs "Hello World!" to the client
```