1
votes

I'm trying to move my ZF2 project to web server. I copied following from my local computer: /config, /data, /module, /public, /vendor and init_autoloader.php. Apache Virtual Host is setup to pointing on /public folder. When I try to run application, browser return error

Fatal error: Uncaught exception 'Zend\Loader\Exception\InvalidArgumentException' with message 'Autoloader class Zend\Loader\StandardAutoloader must implement Zend\Loader\SplAutoloader' in /var/www/vhosts/.../vendor/zendframework/zendframework/library/Zend/Loader/AutoloaderFactory.php:91 Stack trace: #0 /var/www/vhosts/.../vendor/zendframework/zendframework/library/Zend/ModuleManager/Listener/AutoloaderListener.php(34): Zend\Loader\AutoloaderFactory::factory(Array) #1 [internal function]: Zend\ModuleManager\Listener\AutoloaderListener->__invoke(Object(Zend\ModuleManager\ModuleEvent)) #2 /var/www/vhosts/.../vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(468): call_user_func(Object(Zend\ModuleManager\Listener\AutoloaderListener), Object(Zend\ModuleManager\ModuleEvent)) #3 /var/www/vhosts/.../vendor/zendframework/zendframework/library/Zend/EventManag in /var/www/vhosts/.../vendor/zendframework/zendframework/library/Zend/Loader/AutoloaderFactory.php on line 91

Any suggestions? Thanks.

1
are the php versions the same? make sure all that is squared away before moving or migrating the app. issue > php -v on the linux command line or on windows launch cmd and do that same, maybe its php.exe -v, match up the versions and give it a try. after you've done that make sure to restart apache.unixmiah
Php versions are not same, local 5.4.24; web server 5.3.3. I'm just install Skeleton App on local via Composer, and upload on server. I got same error. I notice that .htaccess file in /public folder does not exist. Is this file required?Blagi
that's definitely a requirement. most frameworks have .htacces in them to re-write urls their way.unixmiah

1 Answers

2
votes

This error is due to old php version on your server. 5.3.3 is not enough. You should be aware of limitations:

2.3.0 requires php >=5.3.23
2.4.0 requires php >=5.3.23

You can use zend framework 2.2.10 at php5.3.3. Edit your application/composer.json

"require": {
        "php": ">=5.3.3",
        "zendframework/zendframework": "~2.2"
    }

Then run php composer.phar install, it will reinstall your framework:

>php composer.phar install
Loading composer repositories with package information
Installing dependencies (including require-dev)
  - Removing zendframework/zendframework (2.4.0)
  - Installing zendframework/zendframework (2.2.10)
    Downloading: 100%

Writing lock file
Generating autoload files