Re: Declare minimum PHP version required?

From: Date: Mon, 03 Feb 2014 07:07:31 +0000
Subject: Re: Declare minimum PHP version required?
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-72045@lists.php.net to get a copy of this message
Hi all, On Mon, Feb 3, 2014 at 3:58 PM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote: > I thought it might be good for us to have declaring minimum PHP version > required to execute script. > http://jp1.php.net/manual/en/control-structures.declare.php > > Something like > <?php > declare(php_version>='5.6.0'); > // or PHP_VERSION_ID? using = as minimum as it could be a little faster > // and no change in declare() syntax. > declare(php_version=50600); > > If version mismatches, raise compile error and exit. Something like > > Compile error: PHP 5.6.0 or later is required to compile script. Your PHP > version is 5.x.x. > > The same thing can be done by version_compare() and die(), but it does not > make much sense executing script only to check PHP version and die, > especially for libraries. For library, it is preferred to fail when it is > included, not when it is executed. I wouldn't write version_compare() and > die() for libraries, but I may use it if it's a declare(). If this is > adopted widely, it may help transition to higher versions hoping users to > consider compile error more seriously. > > Issue would be current behavior for unsupported declaration. > $ php -r "declare(php_version=050600);" > Warning: Unsupported declare 'php_version' in Command line code on line 1 > It does not raise E_ERROR, but E_WARNING. > > Just an idea. > Any comments? > It may be good to have Zend API to register required library versions for modules. For example, declare('libxxx_version'=1.0.0); If it does not much, failed at include. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net

« previous php.internals (#72045) next »