How to list compiled PHP Modules

Sometimes is useful to see what modules are compiled in your PHP installation.
Let’s see how we can check this both on the server/root level and on the user level.

1. On the server/root level
On the server level, you can use the command php -m

root@web [~]# php -m
[PHP Modules]
Core
ctype
curl
date
dom
filter
ftp
gd
hash
iconv
imap
ionCube Loader
json
libxml
mbstring
mcrypt
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
soap
SPL
sqlite3
standard
tokenizer
wddx
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache
the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured)

root@web [~]#

An improvement of the above command is to list the version of each module. We will use the command:

root@web [~]# php -r 'foreach (get_loaded_extensions() as $ext) echo "$ext : version " . phpversion($ext) . "\n";'
Core : version 7.0.16
date : version 7.0.16
libxml : version 7.0.16
openssl : version 7.0.16
pcre : version 7.0.16
zlib : version 7.0.16
filter : version 7.0.16
hash : version 1.0
pcntl : version 7.0.16
readline : version 7.0.16
Reflection : version 7.0.16
SPL : version 7.0.16
session : version 7.0.16
standard : version 7.0.16
ctype : version 7.0.16
curl : version 7.0.16
dom : version 20031129
ftp : version 7.0.16
gd : version 7.0.16
iconv : version 7.0.16
imap : version 7.0.16
json : version 1.4.0
mbstring : version 7.0.16
mcrypt : version 7.0.16
mysqlnd : version mysqlnd 5.0.12-dev - 20150407
PDO : version 7.0.16
Phar : version 2.0.2
posix : version 7.0.16
SimpleXML : version 7.0.16
soap : version 7.0.16
sqlite3 : version 0.7-dev
tokenizer : version 7.0.16
xml : version 7.0.16
xmlwriter : version 7.0.16
xsl : version 7.0.16
zip : version 1.13.5
mysqli : version 7.0.16
pdo_mysql : version 7.0.16
pdo_sqlite : version 7.0.16
wddx : version 7.0.16
xmlreader : version 7.0.16
xmlrpc : version 7.0.16
ionCube Loader : version
Zend OPcache : version 7.0.16
root@web [~]#

2. How to check loaded extensions as a user
Create and run a PHP file with the following content:

<?php
foreach (get_loaded_extensions() as $ext) echo “$ext : vers ” . phpversion($ext) . “</br>”;
?>

You will get a list of installed extensions alongside with their versions. To check if a specific extension is loaded, use the PHP function extension_loaded().

More info at PHP.net for the functions get_loaded_extensions() and extension_loaded()

Leave a Reply