Zend框架-错误将无法登录 [英] Zend framework - error wont login
问题描述
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);
}
在OLD PHP和OLD CentOS中,其工作正常,但是当我迁移时
In OLD PHP and OLD CentOS its working but when i migrated to new server its failing.
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步:将旧文件插入composer.lock
Step 2: INSERT the OLD to composer.lock
{
"hash": "3d8fc311b085e1e9bc4ed181947f205d",
"packages": [
{
"package": "zendframework/zendframework",
"version": "2.0.3"
}
],
"packages-dev": null,
"aliases": [
],
"minimum-stability": "stable",
"stability-flags": [
]
}
步骤3:删除新的供应商
Step 3: Remove the NEW vendor
$ rm -fr vendor
第4步:尝试安装并失败
Step 4: try to install and fails
$ ./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致命错误:未捕获错误:调用未定义函数Application\Controller\mysql_real_escape_string()
FAIL: ERROR: PHP Fatal error: Uncaught Error: Call to undefined function Application\Controller\mysql_real_escape_string()
推荐答案
新服务器上真正重要的是您的 vendor /
文件夹内容。看来,一旦您部署了软件,就安装了 composer update
而不是 composer install
的依赖项,或者您没有 composer.lock
文件保留。
It looks that what really matters on new server is your vendor/
folder content. It seems that once you deploy your software you installed dependencies with composer update
instead of composer install
or you do not have composer.lock
file preserved.
快速解决方法是简单地复制 composer.lock
旧计算机上的文件,在新计算机上擦除 vendor /
文件夹,然后重新安装 composer install
则应基于 composer.lock
内容。
The quick fix should be to simply copy composer.lock
file from old machine, wipe vendor/
folder on new one and reinstall doing composer install
which should be then based on composer.lock
content.
编辑
您的composer.lock创建于2012-09-15之前
Your composer.lock was created before 2012-09-15
似乎您的OLD设置确实很旧。您可以做的是更新您的 composer.json
来请求完全与您在旧系统上使用的相同版本。这非常简单,您所需要做的就是查看您在OLD系统上获得的内容并提出新请求。
Seems your OLD setup is really old. What you can do is update your composer.json
to request exactly the same versions you have on old system. This is pretty simple, and all you need to do is see what you got on OLD system and make new request the same.
因此,列出已安装版本的作曲家表演
:
So list installed versions with composer show
:
$ composer show
foo/bar 1.4.3 Some description
....
然后编辑新系统上的composer.json
并更新所有版本约束以指向完全相同的版本。即而不是
Then edit composer.json
on new system and update all version constraint to point to exactly the same version. I.e. instead of
'require': {
'foo/bar': '~1.0',
...
}
您需要输入显示的版本
: foo / bar
的作曲家表演
you need to put version shown by composer show
for that foo/bar
:
'require': {
'foo/bar': '1.4.3',
...
}
然后删除 composer.lock
和 vendor /
并执行 composer install
,您应该会很好。
Then remove composer.lock
and vendor/
and do composer install
and you should be good.
这篇关于Zend框架-错误将无法登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!