1

I've recently upgraded my server to use PHP 7.0. However following this upgrade, I noticed that my web application wasn't working. I looked in my apache2 error.log file and found this error:

PHP Fatal error: Uncaught Error: Class 'Zend_Loader_Autoloader' not found

When I do 'php -v' on the command line, it shows this:

PHP 7.0.0-5+deb.sury.org~trusty+1 (cli) ( NTS ) Copyright (c) 1997-2015 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

It looks like the framework is installed, but for the cli only (not Apache).

Does anyone know how to enable it for Apache?

Thanks.

T Smith
  • 31
  • 4

1 Answers1

2

What you're seeing from php -v doesn't reflect the application framework you're using (in this case, the Zend Framework). The problem more likely lies in the application-level code you're running, which appears to be a Zend Framework 1 app.

I had a very similar error in a ZF1 app that was using Doctrine for its ORM layer. In Doctrine's class loader, I had to add an extra check for PHP 7 to handle some ways in which PHP 7 changes variable interpretation. Around line 224 of library/Doctrine/Common/ClassLoader.php, I changed:

} else if ($loader[0]::$loader[1]($className)) { // array('ClassName', 'methodName')
    return true;
}

to:

} else if {
    if (substr(PHP_VERSION_ID, 0, 1) == '7') {
        $method = $loader[0] . '::' . $loader[1];
        if ($method($className)) { // array('ClassName', 'methodName')
            return true;
        }
    }
    else {
        if ($loader[0]::$loader[1]($className)) {
            return true;
        }
    }
}

Not sure if this will address your issue specifically. If this doesn't work, you could try explicitly requiring the Zend autoloader in your PHP script (presuming that library/Zend is in your include path):

require_once 'Loader/Autoloader.php';

Hope that helps!

GuySMiLEZ
  • 21
  • 2