Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save medeirosinacio/a0e8bf7edf4390cf6c44491f94a95ef9 to your computer and use it in GitHub Desktop.
Save medeirosinacio/a0e8bf7edf4390cf6c44491f94a95ef9 to your computer and use it in GitHub Desktop.
PHP command to List All Extension and Versions

PHP Extension Versions Checker

Overview

This simple PHP command allows you to list all loaded PHP extensions along with their versions. It utilizes the ReflectionExtension class to provide detailed information about each extension.

Usage

php -r '$all = get_loaded_extensions(); foreach($all as $i) { $ext = new ReflectionExtension($i); $ver = $ext->getVersion(); echo "$i - $ver" . PHP_EOL;}'

The command iterates through all loaded extensions, retrieves version information using ReflectionExtension, and prints the extension name along with its version.

Output

Core - 8.2.13
date - 8.2.13
libxml - 8.2.13
pcre - 8.2.13
zlib - 8.2.13
[...]
redis - 6.0.2
swoole - 5.1.1
Zend OPcache - 8.2.13

Notes

  • Ensure that the PHP command is available in your terminal.
  • The output includes extension names and their respective versions.

Feel free to customize and integrate this command into your PHP development workflow.

@medeirosinacio
Copy link
Author

medeirosinacio commented Dec 4, 2023

docker run dumptec/php-fpm:dev-8.3-latest bash -c 'php -r '\''$all = get_loaded_extensions(); foreach($all as $i) { $ext = new ReflectionExtension($i); $ver = $ext->getVersion(); echo "$i - $ver" . PHP_EOL;}'\'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment