Friday, February 11, 2011

Determine minimum required PHP version

I have to find out the earliest PHP4 version my code will run under (I already know it runs on PHP5 and on PHP 4.4.9 (the last PHP4 version -- included in MAMP).

Are there code inspection tools that will do this? Do I need to install each PHP version and see what happens :-)

  • I don't think there is a tool for that. I guess you don't have to install all PHP version, try major releases, like 4.1, 4.2, 4.3, etc To my mind minor releases don't have language syntax changes or anything major, usually it's bug fixes

  • Before you manually download and install various versions of PHP, try to download the XAMPP versions, that have the old php binaries packaged:

    Download links on oldapps.com

    TravisO : I think the best answer is to use the Pear component but it would be wise to then take that min version via XAMPP and actually verify the code works.
    From Cassy
  • There is a PEAR package for this: PHP_CompatInfo

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

    Example: http://pear.php.net/manual/en/package.php.php-compatinfo.basic.php

    TravisO : This is a great answer, but I would also suggest after you find out that version, take Cassy's advice and use an install of that PHP and verify that version really works.
    From powtac
  • I use (unit) tests for this purpose.

    for v in $versions; do
      php$v -f tests.php
    done
    

1 comments:

J Lalchan said...

i like the way, all participation in answering, good effort, please elaborate on the code inspection tools. Thanking you in advance.

Post a Comment