Cross-platform code 4: Coping with php.ini differences

If you have made a lot of changes to your php.ini file, or indeed any changes from the default php.ini file, it is possible that scripts your write will not work elsewhere. The most common culprit is extensions: you've used one on your development machine that isn't available on your production machine.

If you have enabled an extension which is not enabled in someone else's php.ini file, people deploying your script will get lots of errors about undefined functions. The best way around this, other than adding warnings about required extensions in your readme file, is to have a checkconfig.php file that runs checks on the current configuration to make sure it has the correct extensions available.

Alternatively, don't forget that running phpinfo() will show you all the extensions that are installed, along with their current configurations.

 

Want to learn PHP 7?

Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!

If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!

Next chapter: Cross-platform code 5 >>

Previous chapter: Cross-platform code 3: Path and line separators

Jump to:

 

Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.