简体   繁体   中英

PHP 7.2 - Missing extensions returns no errors - Stops execution

I fight with that issue already since Wednesday and the result after my research and tests between PHP 5.6 and PHP 7.2 (also 7.1) are: That my PHP 7 doesn't complains or notices missing extensions in my environment.

Instead of that, it just stops the execuation without an error-message.

Question

Why does PHP 7.x stops executation in the middle of the script* and doesn't fires an Error Notice or Hint for missing PHP-Extensions anymore?

* Mostly at the position where a function requires to use the specific PHP-Extension.

Environment

Operating System :  Debian GNU/Linux 9.6 (stretch)
Web Server       :  nginx/1.10.3
PHP              :  PHP 7.2.12

/etc/apt/sources.list

# deb cdrom:[Debian GNU/Linux 9.2.1 _Stretch_ - Official amd64 NETINST 20171013-13:07]/ stretch main

#deb cdrom:[Debian GNU/Linux 9.2.1 _Stretch_ - Official amd64 NETINST 20171013-13:07]/ stretch main

deb http://ftp.de.debian.org/debian/ stretch main
deb-src http://ftp.de.debian.org/debian/ stretch main

deb http://security.debian.org/debian-security stretch/updates main
deb-src http://security.debian.org/debian-security stretch/updates main

# stretch-updates, previously known as 'volatile'
deb http://ftp.de.debian.org/debian/ stretch-updates main
deb-src http://ftp.de.debian.org/debian/ stretch-updates main

Issue

While PHP 5.6 complains about missing drivers or invalid function, it just stops execuation when necessary in the middle of my code, without an error message.

Example : If some of these extensions aren't installed, the issue happens:

php7.2-mysql
php7.2-mbstring
php7.2-soap
php7.2-simplexml

This issue was really confusing, because I had enabled error-reporting and display-errors, startup-errors in my /etc/php/7.2/fpm/php.ini and also work with...

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

...in my code. But still, no message or error appears for missing extensions.

Isn't PHP 7.2 not able anymore to throw an error, when the function calls missing his necessary extensions? Or is there some misconfiguration in the default-settings of the php.ini ?

What do I miss here?


20181210

Solution

At the end it was my own fault, I've let my Router-Script try/catch Exceptions and Throwables into an variable, but doesn't dumped or debuged them then. Sorry for the whole hasse

Additional important note

To make sure that I made the issue here comprehensible : I can get error-notices and exceptions for most of the common errors like misspelling a function, wrong syntax, declaration, require, missing-file and so on. But my issue here is that PHP 7.2 isn't able to notice that some php-extension is missing and instead to giving some feedback on page or log, it just stops at the function which would/should require the php-extension.

Are you executing php 7.2 using php-fpm? The php.ini does nothing for php-fpm. In this case you need to update the php-fpm.conf file.

The correct lines for php-fpm are:

; enable display of errors
php_flag[display_errors] = on
php_flag[display_startup_errors] = on

Have you tried error_reporting(-1) ?

It appears that error_reporting( E_ALL | E_STRICT) does not process all parse/syntax errors.

See for example:

EDIT : To catch errors/exceptions can also be useful (see comments)

try {
     // Your code
} catch(Throwable $e) {
    echo $e->getMessage();
}

You can catch Error or Throwable (which catches exceptions and errors (> PHP 5))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM