Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List used PHP modules in code base

I need to list all PHP extensions that's required by a given code base. What would be the best way to tackle this problem?

My initial thought is to write a script that goes through all files and find all functions and compare them to a given extension/function database. Any other suggestions?


Update: I already did some Bash script with grep and using get_loaded_modules, get_extension_funcs PHP functions, but this extension is exactly what I was looking for.

like image 347
ibrahim Avatar asked Feb 16 '10 20:02

ibrahim


1 Answers

PHP CompatInfo (not the PEAR extension) is great once you learn how to use it:

  1. Go to PHP CompatInfo site
  2. Download and install the tool
  3. Copy the configuration file contents from their site and put it into a new file named phpcompatinfo.json
  4. run the following command (current dir being the directory where phpcompatinfo.json is placed)

    phpcompatinfo analyser:run . extension

You will get an output like this:

Extensions Analysis

 Extension  REF EXT min/Max PHP min/Max
 Core           4.2.0       4.2.0
 PDO            5.1.0       5.1.0
 Reflection     5.0.0       5.0.0
 calendar       4.0.0       4.0.0
 date           5.3.0       5.3.0
 filter         0.11.0      5.0.0
 gettext        4.0.0       4.0.0
 iconv          4.0.5       4.0.5
 json           5.4.0       5.4.0
 mbstring       4.4.3       4.4.3
 pcre           4.0.0       4.0.0
 session        4.0.3       4.0.3
 spl            5.4.0       5.4.0
 standard       5.5.0       5.5.0
 Total [14]                 5.5.0
like image 141
hegemon Avatar answered Oct 01 '22 01:10

hegemon