Every old PHP4 application faces this question: Does it also run under a newer PHP5 version? Hopefully you have migrated or deprecated all your legacy stuff already… or at least have customers that understand the value of a proper relaunch and are also willing to pay for it.
To make some customer fossils run on a PHP5 host, we did the following dirty hacks:
- Set “AllowOverride All” in your Apache config in order to enable .htaccess files for runtime configuration.
- Copy your legacy app on your new php5 host.
- Place a .htaccess file in the directory containing something like this:
php_flag register_globals on php_flag register_long_arrays on php_flag zend.ze1_compatibility_mode on php_flag short_open_tag on php_value auto_prepend_file "/home/web/my_legacy/_prepend.php"
More info on configuration changes in php and list of ini-directives.
- Place a file called _prepend.php in the same directory and set path info accordingly:
<?php // See also .htaccess file in this dir with more directives set for this site // Php4ify error reporting error_reporting(E_ERROR | E_WARNING | E_PARSE); // Add required include paths to some distant libs $path_arr = array(); $path_arr[] = '/home/web/blah/libs/legacy'; $path_arr[] = '/home/web/blah/libs/whatever'; $path_str = implode(PATH_SEPARATOR, $path_arr); set_include_path( get_include_path() . PATH_SEPARATOR . $path_str);
This is indeed very very dirty and should only be considered as last-resort to make some legacy app runnable under php5 without having to do crazy search-and-replace orgies on old stuff.





RSS