[php] How do I see the extensions loaded by PHP?

It's got to be somewhere in the phpinfo() dump, but I just don't know where. Is it supposed to be under the "Additional Modules" section? Somewhere else? I'm trying to figure out why some extensions don't appear to be loaded, but I don't even know where I should be looking.

This question is related to php php-extension

The answer is


use get_loaded_extensions() PHP function


You want to run:

 php -m 

on the command line,

or if you have access to the server configuration file open

/etc/php5/apache2/php.ini

and look at all the the extensions,

you can even enable or disable them by switching between On and Off like this

<Extension_name> = <[On | Off]>

use get_loaded_extensions() PHP function


If you want to test if a particular extension is loaded you can also use the extension_loaded function, see documentation here

php -r "var_dump(extension_loaded('json'));"

get_loaded_extensions() output the extensions list.

phpinfo(INFO_MODULES); output the extensions and their details.


Are you looking for a particular extension? In your phpinfo();, just hit Ctrl+F in your web browser, type in the first 3-4 letters of the extension you're looking for, and it should show you whether or not its loaded.

Usually in phpinfo() it doesn't show you all the loaded extensions in one location, it has got a separate section for each loaded extension where it shows all of its variables, file paths, etc, so if there is no section for your extension name it probably means it isn't loaded.

Alternatively you can open your php.ini file and use the Ctrl+F method to find your extension, and see if its been commented out (usually by a semicolon near the start of the line).


Running

php -m
will give you all the modules, and
php -i
will give you a lot more detailed information on what the current configuration.


use get_loaded_extensions() PHP function


Running

php -m
will give you all the modules, and
php -i
will give you a lot more detailed information on what the current configuration.


Are you looking for a particular extension? In your phpinfo();, just hit Ctrl+F in your web browser, type in the first 3-4 letters of the extension you're looking for, and it should show you whether or not its loaded.

Usually in phpinfo() it doesn't show you all the loaded extensions in one location, it has got a separate section for each loaded extension where it shows all of its variables, file paths, etc, so if there is no section for your extension name it probably means it isn't loaded.

Alternatively you can open your php.ini file and use the Ctrl+F method to find your extension, and see if its been commented out (usually by a semicolon near the start of the line).


  <?php 
      echo "<pre>";
      print_r(get_loaded_extensions());
      echo "<pre/>";
 ?>

Are you looking for a particular extension? In your phpinfo();, just hit Ctrl+F in your web browser, type in the first 3-4 letters of the extension you're looking for, and it should show you whether or not its loaded.

Usually in phpinfo() it doesn't show you all the loaded extensions in one location, it has got a separate section for each loaded extension where it shows all of its variables, file paths, etc, so if there is no section for your extension name it probably means it isn't loaded.

Alternatively you can open your php.ini file and use the Ctrl+F method to find your extension, and see if its been commented out (usually by a semicolon near the start of the line).


You want to run:

 php -m 

on the command line,

or if you have access to the server configuration file open

/etc/php5/apache2/php.ini

and look at all the the extensions,

you can even enable or disable them by switching between On and Off like this

<Extension_name> = <[On | Off]>

use get_loaded_extensions() PHP function


If you want to test if a particular extension is loaded you can also use the extension_loaded function, see documentation here

php -r "var_dump(extension_loaded('json'));"

You asked where do you see loaded extensions in phpinfo() output.

Answer:

They are listed towards the bottom as separate sections/tables and ONLY if they are loaded. Here is an example of extension Curl loaded.

enter image description here ...

... enter image description here

I installed it on Linux Debian with

sudo apt-get install php7.4-curl

Run command. You will get installed extentions:

php -r "print_r(get_loaded_extensions());"

Or run this command to get all module install and uninstall with version

dpkg -l | grep php5

get_loaded_extensions() output the extensions list.

phpinfo(INFO_MODULES); output the extensions and their details.


You asked where do you see loaded extensions in phpinfo() output.

Answer:

They are listed towards the bottom as separate sections/tables and ONLY if they are loaded. Here is an example of extension Curl loaded.

enter image description here ...

... enter image description here

I installed it on Linux Debian with

sudo apt-get install php7.4-curl

Are you looking for a particular extension? In your phpinfo();, just hit Ctrl+F in your web browser, type in the first 3-4 letters of the extension you're looking for, and it should show you whether or not its loaded.

Usually in phpinfo() it doesn't show you all the loaded extensions in one location, it has got a separate section for each loaded extension where it shows all of its variables, file paths, etc, so if there is no section for your extension name it probably means it isn't loaded.

Alternatively you can open your php.ini file and use the Ctrl+F method to find your extension, and see if its been commented out (usually by a semicolon near the start of the line).