brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: php --ri prints the settings of one PHP extension

Php
~/tips/tip-php-ri-extension-info

php --ri curl

Shows the same details as phpinfo() for a single extension, straight in the terminal.

WordPress asks for certain PHP extensions, and a plugin that wants one tells you only after it fails. Scrolling through a full phpinfo() page for that is silly. You can ask for one extension at a time.

php --ri curl

The manual says --ri (long form --rextinfo) shows the configuration information for the given extension, the same information that phpinfo() returns. On PHP 8.3.6 the first lines for curl are:

curl

cURL support => enabled
cURL Information => 8.5.0

The core configuration is available by using main as the extension name:

php --ri main

To see which extensions exist at all, php -m lists the compiled-in modules.

It also works as a yes-or-no test in a script. For a name that isn’t loaded, PHP prints a message and exits with 1:

$ php --ri nonexistent
Extension 'nonexistent' not present.
$ echo $?
1

Caveats: the name you pass is the extension’s own name, which isn’t always the one you’d guess. On the same machine php --ri opcache answers that the extension isn’t present, while php --ri "Zend OPcache" prints its settings. When in doubt, look at the php -m list first. And as with --ini, this describes the command-line PHP, not necessarily the one your web server runs.

Further reading: PHP manual: command line options

More Php tips php --ini All Php tips (2) All topics

Link