PHP_CompatInfo

Find out the minimum version and the extensions required for a piece of code to run.

2013-12-13: PHP_CompatInfo 2.26.0 Released

Release highlights:

  • Add both support to PHP 5.4.23 and 5.5.7

Read the CHANGELOG for a full list of all additions, changes and bug fixes. Changes are documented in the updated User Guide. See the Installation page for downloads and installation instructions.

Laurent Laville

Introduction

PHP_CompatInfo is a PHP library that will parse source code (file, directory) to find out the minimum version and extensions required for it to run. A CLI tool is available, giving results without having to write a line of code.

The major version 2 is a full rewrite to PHP5 that uses exceptions to raise errors, and an autoloader to dynamically load required classes.

Since version 2.0.0RC3 the PHP parser engine used is PHP_Reflect. It’s an improved version from the basic concept of PHP_TokenStream.

If you want a PHP4-compatible version, you should consider to have a look on the branch 1.x solution hosted on PEAR repository : PEAR::PHP_CompatInfo 1.9.0

Caution
Its recommended to migrate to PHP5, because the PHP4 version is not maintained anymore.

Features

  • Parse a single file

  • Parse a directory recursively or not

  • Parse a list of files and/or directories

  • Ability to give a list of extensions to ignore when calculating the version needed

  • Ability to give a list of interfaces to ignore when calculating the version needed

  • Ability to give a list of traits to ignore when calculating the version needed

  • Ability to give a list of classes to ignore when calculating the version needed

  • Ability to give a list of functions to ignore when calculating the version needed

  • Ability to give a list of constants to ignore when calculating the version needed.

  • Ability to give a list of files to ignore when calculating the version needed

  • Ability to give a list of directories to ignore when calculating the version needed

  • Ability to use a custom extensions list or by default only extensions loaded, to parse PHP code

  • Event driven and listeners system to audit parsing process

Requirements

  • PHP 5.3.0 or newer

  • Console_CommandLine 1.2.0 or newer from default PEAR channel

  • PHP_Reflect 1.9.0 or newer from Bartlett PEAR channel

  • tokenizer extension

  • pcre extension

  • SPL extension

  • DOM extension

  • libxml extension

  • Reflection extension

  • (optional) PEAR 1.9.0 or newer from default PEAR channel

  • (optional) Net_Growl 2.6.0 or newer from default PEAR channel

  • (optional) PHPUnit 3.6.0 or newer from PHPUnit PEAR channel

  • (optional) PHP_Timer 1.0.0 or newer from PHPUnit PEAR channel

  • (optional) an XSLT processor if you want to produce an xHTML report from a phpci xml report

Extensions supported

Version Count New extensions since previous version
2.0.0 61
2.1.0 63 memcache, memcached
2.2.0 65 ldap, oauth
2.3.0 67 Reflection, Zip
2.4.0 67
2.5.0 75 exif, lzf, mailparse, mssql, solr, sphinx, xhprof, Yaml
2.6.0 75
2.7.0 75
2.8.0 80 amqp, geoip, inclued, mongo, XCache
2.9.0 80
2.10.0 83 igbinary, imagick, odbc
2.11.0 83
2.12.0 83
2.13.0 84 svn
2.14.0 84
2.15.0 86 varnish, Zend OPcache
2.16.0 95 APCu, gender, haru, http, libevent, msgpack, pthreads, stomp, uploadprogress
2.17.0 95
2.18.0 95
2.19.0 95
2.20.0 95
2.21.0 95
2.22.0 95
2.23.0 98 htscanner, Rar, PDFlib
2.24.0 98
2.25.0 99 jsmin
2.26.0 100 riak

The phpcompatinfo tool may inform you on what of those extensions are or not loaded on your system.

Run command

    $ phpcompatinfo list-references

Will output results as follow. May differ depending of your extensions loaded.

    -------------------------------------------------------------------------------
    PHP COMPAT INFO DATABASE REFERENCE
    -------------------------------------------------------------------------------
      EXTENSION                             VERSION           PHP min/Max
    -------------------------------------------------------------------------------
      amqp                                  1.2.0             5.2.0
      apc                                   3.1.13            4.3.0
    L apcu                                  4.0.2             5.3.0
    L bcmath                                                  4.0.0
    L bz2                                                     4.0.4
    L calendar                                                4.0.0
      Core                                  5.5.7             4.0.0
    L ctype                                                   4.0.4
    L curl                                                    4.0.2
    L date                                                    4.0.0
    L dom                                   20031129          5.0.0
      enchant                               1.1.0             5.0.0
      ereg                                                    4.0.0/5.3.27
    L exif                                                    4.0.1
      fileinfo                              1.0.5             4.0.0
    L filter                                0.11.0            4.0.0
    L ftp                                                     4.0.0
    L gd                                                      4.0.0
      gender                                1.0.0             5.3.0
      geoip                                 1.0.8             4.3.0
    L gettext                                                 4.0.0
      gmp                                                     5.1.0
      haru                                  1.0.4             5.1.3
    L hash                                  1.0               4.0.0
      htscanner                             1.0.1             5.2.0
      http                                  2.0.3             5.3.0
    L iconv                                                   4.0.5
      igbinary                              1.1.1             5.2.0
      imagick                               3.1.2             5.1.3
    L imap                                                    4.0.0
      inclued                               0.1.3             5.1.0
      intl                                  3.0.0             5.2.0
      jsmin                                 0.1.1             5.3.10
    L json                                  1.2.1             5.2.0
    L ldap                                                    4.0.0
      libevent                              0.1.0             5.3.0
    L libxml                                                  5.0.0
      lzf                                   1.6.2             4.0.0
      mailparse                             2.1.6             4.3.0
    L mbstring                                                4.0.6
    L mcrypt                                                  4.0.0
      memcache                              3.0.8             4.3.11
      memcached                             2.2.0b1           5.2.0
    L mhash                                                   4.0.0/5.2.17
      mongo                                 1.4.4             5.0.0
      msgpack                               0.5.5             5.0.0
      mssql                                                   4.0.0
    L mysql                                 1.0               4.0.0
    L mysqli                                0.1               5.0.0
      OAuth                                 1.2.3             5.1.0
    L odbc                                                    4.0.0
    L openssl                                                 4.0.4
      pcntl                                                   4.1.0
    L pcre                                                    4.0.0
      PDFlib                                3.0.1             5.2.0
    L PDO                                   1.0.4dev          5.1.0
      pgsql                                                   4.0.0
      Phar                                  2.0.1             5.2.0
      posix                                 306939            4.0.0
      pthreads                              0.45              5.3.0
      rar                                   3.0.1             5.2.0
      readline                              2.0.1             4.0.0
      recode                                2.0.1             4.0.0
      riak                                  1.0.0             5.3.0
    L Reflection                                              5.0.0
    L session                                                 4.0.0
    L shmop                                                   4.0.0
    L SimpleXML                             0.1               5.0.0
      snmp                                  0.1               4.0.0
    L soap                                                    5.0.0
    L sockets                                                 4.1.0
      solr                                  1.0.2             5.2.3
      sphinx                                1.3.0             5.1.3
    L SPL                                   0.2               5.0.0
    L SQLite                                2.0-dev           5.0.0
      sqlite3                               0.7               5.3.0
      ssh2                                  0.12              4.0.0
    L standard                              5.5.7             4.0.0
      stomp                                 1.0.5             5.2.2
    L svn                                   1.0.2             4.0.0
      sysvmsg                               306939            4.3.0
      sysvsem                                                 4.0.0
      sysvshm                                                 4.0.0
    L tidy                                  2.0               4.3.0
    L tokenizer                             0.1               4.2.0
      uploadprogress                        1.0.3.1           5.2.0
      varnish                               1.1.1             5.3.0
    L wddx                                                    4.0.0
      XCache                                3.1.0             4.3.0
    L xdebug                                2.2.3             4.3.0
      xhprof                                0.9.4             5.2.0
    L xml                                                     4.0.0
    L xmlreader                             0.1               5.0.0
    L xmlrpc                                0.51              4.1.0
    L xmlwriter                             0.1               5.1.2
    L xsl                                   0.1               5.0.0
      yaml                                  1.1.0             5.2.0
      Zend OPcache                          7.0.3-dev         5.2.0
    L zip                                   1.12.3            4.3.0
    L zlib                                  2.0               4.3.0
    -------------------------------------------------------------------------------
    A TOTAL OF 100 EXTENSIONS WERE FOUND AND 49 LOADED
    -------------------------------------------------------------------------------
    Time: 1 second, Memory: 5.25Mb
    -------------------------------------------------------------------------------
  • The L flag tells us what extensions are loaded

  • The VERSION column specify the version of extension that was documented

  • The PHP min/Max column specify which are the php versions (minimum and maximum) supported by the extension

Documentation

Head to the PHP_CompatInfo User Guide available online for information or examples to get started.

The PHP_CompatInfo book is available in a selection of formats. You can download the documentation for offline reading.

Language Single HTML file Many HTML files HTML Help file PDF A4 file PDF US file EPUB file
English phpci-book.html.zip phpci-book.chunked.zip phpci-book.chm.zip phpci-book-a4.pdf phpci-book-us.pdf phpci-book.epub.zip

Appendixes

Changelog

You want to learn more about previous versions. Read the full changelog.

License

You are free to do whatever you want, even in a commercial environment. You are also encouraged to contribute. Read the full license.

Credits

I would like to thanks here specially a guy without who this PHP QA tool won’t be born.

Original author, he introduced his proposal in 2004, that gave birth of a PEAR package named PHP_CompatInfo.

http://daveyshafik.com/ Davey Shafik

I would also like to thanks a guy who help me to enhance support of more than 50 extensions.

Contributor of many extensions reference and unit tests. He has joined the team on version 2.0.0RC2

http://blog.famillecollet.com/ Remi Collet

All pages of this site, and user guide were generated with AsciiDoc 8.6.8, assisted by FOP 1.0 (for PDFs). Automated build process uses Phing 2.6.1

Convert the HTML Help source (.hhp and .html) files to HTML Help (.chm) files using the Microsoft HTML Help Compiler.