DEV Community

loading...
Cover image for PHP Quick Tip: How to check loaded extensions on CLI

PHP Quick Tip: How to check loaded extensions on CLI

sonyarianto profile image Sony AK ・1 min read

Suppose we have PHP installed on our machine and we want to quick check what extensions loaded on our PHP. Plus you just want to know through CLI. It's easy.

Usually I just type this.

php -i
Enter fullscreen mode Exit fullscreen mode

It will display complete information about PHP and all its configuration. It is similar like we call phpinfo() function.

The second is typing this command.

php -r "print_r(get_loaded_extensions());"
Enter fullscreen mode Exit fullscreen mode

It will display loaded extensions only. The result example is like below.

Array
(
    [0] => Core
    [1] => date
    [2] => libxml
    [3] => openssl
    [4] => pcre
    [5] => zlib
    [6] => filter
    [7] => hash
    [8] => pcntl
    [9] => Reflection
    [10] => SPL
    [11] => sodium
    [12] => session
    [13] => standard
    [14] => mysqlnd
    [15] => PDO
    [16] => xml
    [17] => bcmath
    [18] => calendar
    [19] => ctype
    [20] => curl
    [21] => dom
    [22] => mbstring
    [23] => fileinfo
    [24] => ftp
    [25] => gd
    [26] => gettext
    [27] => iconv
    [28] => igbinary
    [29] => imap
    [30] => json
    [31] => exif
    [32] => msgpack
    [33] => mysqli
    [34] => pdo_mysql
    [35] => Phar
    [36] => posix
    [37] => readline
    [38] => shmop
    [39] => SimpleXML
    [40] => sockets
    [41] => sysvmsg
    [42] => sysvsem
    [43] => sysvshm
    [44] => tokenizer
    [45] => wddx
    [46] => xmlreader
    [47] => xmlwriter
    [48] => xsl
    [49] => memcached
    [50] => Zend OPcache
)
Enter fullscreen mode Exit fullscreen mode

Thank you and I hope you enjoy it.

Credits

Discussion

pic
Editor guide