PHP Handling errors / exceptions related to missing extensions

Many times there is a particular PHP extension necessary for the operation of our PHP application.

The hard part is that we cannot check every extension that our project requires when we use the framework. We assume that some of these extensions are popular and should be enabled by default.

Sometimes a user installs our application on a fresh / dedicated server with not very well configured PHP, and even some basic extension, which we assume should be active, is not.

Is there any class in which extensions-related errors can be detected. Therefore, basically, when an error occurs related to a certain extension, we can direct the user to a special page and ask them to enable these extensions, therefore they do not consider that the error is related to the application, but to the absence of an missing extension.

How can we improve exception handling for such errors / exceptions?

+4
source share
1 answer

PHP, Laravel. Laravel mcrypt, mbstring, openssl.. .. , / -/ PHP. .

PHP extension_loaded, , .

if(!extension_loaded('mcrypt')){
    //maybe try to load it or display a nice 404 error page
}

index.php 404/500, .

+1

Source: https://habr.com/ru/post/1649117/


All Articles