Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate emitter from the Application #65

Merged
merged 1 commit into from
Feb 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

use hiqdev\composer\config\Builder;
use Yiisoft\Di\Container;
use Yiisoft\Http\Method;
use Yiisoft\Yii\Web\Application;
use Yiisoft\Yii\Web\Emitter\EmitterInterface;
use Yiisoft\Yii\Web\ServerRequestFactory;

require_once dirname(__DIR__) . '/vendor/autoload.php';
Expand All @@ -25,5 +27,15 @@

require_once dirname(__DIR__) . '/src/globals.php';

$application = $container->get(Application::class);
$emitter = $container->get(EmitterInterface::class);

$request = $container->get(ServerRequestFactory::class)->createFromGlobals();
$container->get(Application::class)->handle($request);

try {
$application->start();
$response = $application->handle($request);
$emitter->emit($response, $request->getMethod() === Method::HEAD);
} finally {
$application->shutdown();
}