Re: Declare minimum PHP version required?
| From: | Lester Caine | Date: | Mon, 03 Feb 2014 11:17:46 +0000 |
| Subject: | Re: Declare minimum PHP version required? | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-72080@lists.php.net to get a copy of this message | ||
Yasuo Ohgaki wrote:
I don't see how one can eliminate checking if a module is available. I do not load MySQL on my systems so if someone tries to run a script requiring MySQL they need a warning that it's not available. The build of PHP running ensures that the available built in modules are of the right version, but it's the third party libraries that I need to ensure are compatible with the version of PHP I'm trying to run, and that the necessary extensions for that library are loaded. Stuff updated to PHP5.5 may not work on the systems that are still running PHP5.4 for compatibility reasons ... -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.ukThe same thing can be done by version_compare() and die(), but it doesnotmake much sense executing script only to check PHP version and die, especially for libraries. For library, it is preferred to fail when it isWhy not? That's what PHP does - executing scripts.included, not when it is executed. I wouldn't write version_compare() andI don't understand - what is the difference? In PHP including and executing is the same thing. I think version_compare works just fine. I works, but it requires CPU time for it and evaluation is delayed at run time, not compile time. Isn't it nice to know requirement is not met? We may extend declare() more. For example, loaded extensions. declare(module='pgsql,openssl'); With this, we could eliminate code like if (!extension_loaded('foo')) { die('You need foo module'); } if (!extension_loaded('bar')) { die('You need bar module'); } With opcache loaded extension check may be completely skipped. Evaluation at compile time and run time differs.