TL;DR: MAKE PHP5 CODES WORK AGAIN!
You have an old project that can't be changed easily to work with PHP7?
GREAT! We have a few of them at work but I couldnt find anything like this on the whole Internet.
So here is a wrapper for all some depricated and removed functions to make your PHP5 work on PHP7.
At first you will need all the things PHP7 has not onboard on a Ubuntu 16.04 by default.
apt-get install php-apcu php-xml php-mbstring
- The APC was removed and you have to install php-apcu
- In case you have done something with DOMDocument or similar functions you will need php-xml
- Yes, multibyte strings are an extra package php-mbstring
To use it in your project just import it
require_once('php7emulator.php');
In case you have some servers running PHP5 and PHP7 and you need compatibility, just check for an removed function like this:
if (!function_exists('mysql_connect'))
{
require_once(RAWBASEDIR.'/application/helper/php7emulator.php');
}
- In case of FATAL ERROR, go to your error.log, find the missing function and write a wrapper for it.
- Repeat 1. until there are no FATAL ERRORs.
- there are a LOT of missing functions, CATCH EM ALL!
- better Doku?
MIT
Free Software, Hell Yeah!
- thanks to my boss who allowed me to publish it :)
- Blogpost: TBD