How to check if PECL extension is present?

Prof. Falken picture Prof. Falken · May 17, 2013 · Viewed 16.3k times · Source

How do I from PHP code if a PECL extension is installed or not?

I want gracefully handle the case when an extension is not installed.

Answer

bitWorking picture bitWorking · May 17, 2013

I think the normal way would be to use extension-loaded.

if (!extension_loaded('gd')) {
    // If you want to try load the extension at runtime, use this code:
    if (!dl('gd.so')) {
        exit;
    }
}