sameold
sameold

Reputation: 19242

How to print a list of extensions compiled with php

I'm trying to find out what extensions are compiled with the php binary I've been given. Is there a way to do this programmatically?

For example, it's possible to check what version of an extension/library is there

var_dump(curl_version());

but this means I have to check one by one, and I may not be able to guess all libraries compiled within. So anyway to get php to tell me what extensions it has compiled?

Upvotes: 1

Views: 2968

Answers (2)

nickb
nickb

Reputation: 59699

How about the get_loaded_extensions() function?

You can use it in combination with phpversion() which will give you the version for PHP and (if provided as parameter) the extension:

$a = array_map(function($e) { return sprintf("%s (%s)", $e, phpversion($e)); }, get_loaded_extensions());
echo implode('<br>', $a);

Demo

Upvotes: 7

Mike B
Mike B

Reputation: 32155

php -m in the console will show you a list of modules. Not sure if that counts as 'programmatic'.

Upvotes: 3

Related Questions