The compatibility classes provided with these migration guides use PSR-0 for greater compatibility with legacy autoloaders. If the project uses the Zend Framework 1 autoloader, just drop the Compatibility
folder into the lib directory of the project, or whichever folder contains the Zend library. Example:
lib/
├─ Compatibility/
├─ Zend/
If no autoloader exists, here is the suggested PSR-0 autoloader implementation from the FIG website:
function autoload($className)
{
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strrpos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
require $fileName;
}
spl_autoload_register('autoload');
Alternatively, if you only need to use the class in one or two places, you can forego the autoloader and require the file directly, provided that the folder is in the include_path
ini setting:
require_once 'Compatibility/Php56.php';
Migration Services
Increase security and cut risk by simplifying PHP application upgrades and migrations.
Get Long-Term Support With ZendPHP
Stay secure and compliant while migrating on your schedule with Zend PHP LTS.