1

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.

0

2 Answers 2

1

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))

Sign up to request clarification or add additional context in comments.

3 Comments

Hello, this was set first, I thought E_ALL | E_STRICT could more results. Changed back, but no result.
OK, I would suggest to try the Frank Forte's answer in stackoverflow.com/questions/1053424/… (catch exception). Error handling has changed in PHP 7...
Thank you, this has pointed me to the correct direction and let me found out, that I "Stupid" was so smart to try and catch an error at the beginning of the whole application in my PSR-Router Script, which doesn't returned his results into an variable or dump. It's a good idea to catch errors into an variable, but stupid if you don't dump/debug it then. I getting the errors now for every missing extension. Thank you two and sorry that I toke so much time and hassle.
1

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

4 Comments

Doesn't know, but I could swear that php.ini worked in the past, too. I've added the lines, but no change/result. (restarted php7.2-fpm)
@Sascha Try using php_admin_flag instead of php_flag then.
That's strange. Is there a catch_workers_output = yes in your config file?
Tried that now, too. But still no result. And this time I tried that before and after reinstalling a fresh Debian 9.6 from a netinstall.iso. (no packages selected, manual apt installed nginx, php-fpm, openssh, etc, again) Only external source which got included again was the Sury-Repository for php7.2. But I've one important hint, I maybe forget to mention: I can still get errors, if I do something wrong, I get most of the times a notice or exception. But my problem here is, that missing extensions aren't firing an error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.