|
1 | 1 | <?php |
2 | 2 |
|
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; |
10 | 4 |
|
11 | 5 | define('YII_ENV', 'testing'); |
12 | 6 |
|
|
29 | 23 |
|
30 | 24 | require_once dirname(__DIR__) . '/vendor/autoload.php'; |
31 | 25 |
|
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