yiisoft / app

Yii3 application template

Home Page:https://www.yiiframework.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Catching server errors on initializing while working in browser

sankaest opened this issue · comments

commented

What steps will reproduce the problem?

  1. install from scratch yiisoft/app
  2. make configuration for using directly via browser (/etc/hosts + sites-available + a2ensite + systemctl reload apache2)
  3. open web page in browser

What is the expected result?

working web page

What do you get instead?

nothing, just blank (white) page

Additional info

After addiing in index.php

ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);

correct error occurs on web page:
PHP Fatal error: Declaration of Yiisoft\Log\Logger::log(mixed $level, Stringable|string $message, array $context = []): void must be compatible with Psr\Log\LoggerTrait::log($level, $message, array $context = [])

If init in console: /dev/app$ ./yii serve '127.0.0.1:8080', you can see the error directly in console. But if via browser, there is no clue that there is an error.

Q A
Version master
PHP version 8.0.16
Operating system 5.13.0-48-generic # 54~20.04.1-Ubuntu SMP Thu Jun 2 23:37:17 UTC 2022 x86_64
Build System Linux
PHP Server API FPM/FastCGI

It happens here just before the handler that displays nice HTML is registered: https://github.com/yiisoft/yii-runner-http/blob/485037e7e9fad9c406bb4e1072ec260de63a4a45/src/HttpApplicationRunner.php#L129

I'm not sure we can improve it in any way and it won't happen in real user apps since composer won't let to install it. This time it is because we updated to latest PSR and yii-dev-tool setup was using old logger.