gpt4 book ai didi

php - Zend 框架 - 错误不会登录

转载 作者:行者123 更新时间:2023-12-04 19:43:13 24 4
gpt4 key购买 nike

CentOS 3.10.0-327.36.3.el7.x86_64, PHP 7.0.12 .

  public function render($html, $input) {
$view = new ViewModel($input);
$view->setTemplate($html);
$viewRenderer = $this->getServiceLocator()->get('ViewRenderer');
return $viewRenderer->render($view);

}

在旧 PHP 和旧 CentOS 中它可以工作,但是当我迁移到新服务器时它失败了。
PHP Deprecated:  You are retrieving the service locator from within the class Application\\Controller\\MainController. 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/xxmanager/vendor/zendframework/zend-mvc/src/Controller/AbstractController.php on line 258, referer: https://xx.xx.com/



244 /**
245 * Retrieve serviceManager instance
246 *
247 * @return ServiceLocatorInterface
248 */
249 public function getServiceLocator()
250 {
251 trigger_error(sprintf(
252 'You are retrieving the service locator from within the class %s. Please be aware that '
253 . 'ServiceLocatorAwareInterface is deprecated and will be removed in version 3.0, along '
254 . 'with the ServiceLocatorAwareInitializer. You will need to update your class to accept '
255 . 'all dependencies at creation, either via constructor arguments or setters, and use '
256 . 'a factory to perform the injections.',
257 get_class($this)
258 ), E_USER_DEPRECATED);
259
260 return $this->serviceLocator;
261 }

编辑:

第 1 步:删除新的
$ echo '' > composer.lock

第 2 步:将 OLD 插入 composer.lock
{
"hash": "3d8fc311b085e1e9bc4ed181947f205d",
"packages": [
{
"package": "zendframework/zendframework",
"version": "2.0.3"
}
],
"packages-dev": null,
"aliases": [

],
"minimum-stability": "stable",
"stability-flags": [

]
}

第 3 步:删除新供应商
$ rm -fr vendor

第四步:尝试安装失败
$ ./composer.phar install


[RuntimeException]
Your composer.lock was created before 2012-09-15, and is not supported anymore. Run "composer update" to generate a new one.


install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...

编辑 2:
# cat composer.json 
{
"name": "zendframework/skeleton-application",
"description": "Skeleton Application for ZF2",
"license": "BSD-3-Clause",
"keywords": [
"framework",
"zf2"
],
"homepage": "http://framework.zend.com/",
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "2.2.10"
}
}

# php composer.phar install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
- Installing zendframework/zendxml (1.0.2): Loading from cache
- Installing zendframework/zendframework (2.2.10): Downloading (100%)
zendframework/zendframework suggests installing doctrine/annotations (Doctrine Annotations >=1.0 for annotation features)
zendframework/zendframework suggests installing ext-intl (ext/intl for i18n features (included in default builds of PHP))
zendframework/zendframework suggests installing ircmaxell/random-lib (Fallback random byte generator for Zend\Math\Rand if OpenSSL/Mcrypt extensions are unavailable)
zendframework/zendframework suggests installing ocramius/proxy-manager (ProxyManager to handle lazy initialization of services)
zendframework/zendframework suggests installing zendframework/zendpdf (ZendPdf for creating PDF representations of barcodes)
zendframework/zendframework suggests installing zendframework/zendservice-recaptcha (ZendService\ReCaptcha for rendering ReCaptchas in Zend\Captcha and/or Zend\Form)
Writing lock file
Generating autoload files

失败:
错误:PHP fatal error :未捕获错误:调用未定义函数 Application\Controller\mysql_real_escape_string()

最佳答案

看来在新服务器上真正重要的是您的 vendor/文件夹内容。似乎一旦你部署了你的软件,你就安装了 composer update 的依赖项。而不是 composer install或者您没有 composer.lock文件保存。

快速修复应该是简单地复制 composer.lock旧机器上的文件,删除 vendor/新文件夹并重新安装 composer install那么应该基于composer.lock内容。

编辑

Your composer.lock was created before 2012-09-15



似乎您的旧设置真的很旧。你可以做的是更新你的 composer.json请求 正是 与旧系统上的相同版本。这很简单,你需要做的就是看看你在旧系统上得到了什么,并提出相同的新请求。

所以用 composer show 列出已安装的版本:
$ composer show

foo/bar 1.4.3 Some description
....

然后编辑 composer.json在新系统上并更新所有版本约束以指向完全相同的版本。 IE。代替
'require': {
'foo/bar': '~1.0',
...
}

您需要输入 composer show 显示的版本对于那个 foo/bar :
'require': {
'foo/bar': '1.4.3',
...
}

然后删除 composer.lockvendor/composer install你应该很好。

关于php - Zend 框架 - 错误不会登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45505665/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com