Skip to content

Commit ea68545

Browse files
authored
Fix #50: Use ApplicationRunner in index-test.php
1 parent dca071a commit ea68545

1 file changed

Lines changed: 6 additions & 33 deletions

File tree

public/index-test.php

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
<?php
22

3-
use Psr\Container\ContainerInterface;
4-
use Yiisoft\Config\Config;
5-
use Yiisoft\Di\Container;
6-
use Yiisoft\Http\Method;
7-
use Yiisoft\Yii\Web\Application;
8-
use Yiisoft\Yii\Web\SapiEmitter;
9-
use Yiisoft\Yii\Web\ServerRequestFactory;
3+
use App\ApplicationRunner;
104

115
define('YII_ENV', 'testing');
126

@@ -29,29 +23,8 @@
2923

3024
require_once dirname(__DIR__) . '/vendor/autoload.php';
3125

32-
$config = new Config(
33-
dirname(__DIR__),
34-
'/config/packages', // Configs path.
35-
);
36-
37-
$startTime = microtime(true);
38-
$container = new Container(
39-
$config->get('web'),
40-
$config->get('providers'),
41-
);
42-
43-
$container = $container->get(ContainerInterface::class);
44-
$application = $container->get(Application::class);
45-
46-
$request = $container->get(ServerRequestFactory::class)->createFromGlobals();
47-
$request = $request->withAttribute('applicationStartTime', $startTime);
48-
49-
try {
50-
$application->start();
51-
$response = $application->handle($request);
52-
$emitter = new SapiEmitter();
53-
$emitter->emit($response, $request->getMethod() === Method::HEAD);
54-
} finally {
55-
$application->afterEmit($response ?? null);
56-
$application->shutdown();
57-
}
26+
$runner = new ApplicationRunner();
27+
// Development mode:
28+
$runner->debug();
29+
// Run application:
30+
$runner->run();

0 commit comments

Comments
 (0)