Zend Framework - 安装后在CentOS 7上出现错误

时间:2018-02-19 10:18:19

标签: php zend-framework zend-framework2 centos7

在CentOS 7中,ZF2第一次从另一台服务器镜像,ZF2发出以下错误:

PHP Fatal error: Uncaught exception 'RuntimeException' with message 'Unable to load ZF2. Run php composer.phar install or define a ZF2_PATH environment variable.' in /home/www/html/manager/init_autoloader.php:48\nStack trace:\n#0 /home/www/html/manager/public/index.php(9): require()\n#1 {main}\n thrown in /home/www/html/manager/init_autoloader.php on line 48

因此,我已经完成了以下

php composer.phar self-update
php composer.phar update

从那以后它永远失败:

[Mon Feb 19 10:13:00.129063 2018] [:error] [pid 7763] [client 4xxxxxx:60336] PHP Deprecated:  You are retrieving the service locator from within the class Application\\Controller\\IndexController. Please be aware that ServiceLocatorAwareInterface is deprecated and will be removed in version 3.0, along with the ServiceLocatorAwareInitializer. You will need to update your class to accept all dependencies at creation, either via constructor arguments or setters, and use a factory to perform the injections. in /home/www/html/manager/vendor/zendframework/zend-mvc/src/Controller/AbstractController.php on line 258

我该如何解决?

1 个答案:

答案 0 :(得分:1)

composer updatecomposer install命令执行的操作非常不同。

虽然composer install安装composer.lock文件中的特定版本中的所有预定义依赖项,composer update会尝试将它们更新为最新版本并写入新的锁文件。

this answer on SOthis thread on GitHub中所述的最近版本的控制器中删除ServiceLocatorAwareInterface后,如果您只想镜像现有项目,则需要使用composer install保持功能不变。