【发布时间】:2017-02-07 09:30:38
【问题描述】:
在从 PHP 5.5 升级到 PHP 7.0 的过程中,Symfony 项目遇到了一个问题。
已遵循http://www.doctrine-project.org/2016/06/09/odm-1-1-0-and-1-0-6.html 中的步骤以确保 mongo-ext 与学说兼容。没有发生兼容性升级。
但是会出现以下异常:
PHP Fatal error: Cannot use 'String' as class name as it is reserved in
... vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/String.php on line 26
该问题很可能与 composer.json 中的配置问题有关
哪个要求阻止 composer update 安装正确的学说/mongodb?
PHP 版本 7.0.13-0ubuntu0.16.04.1 (cli) (NTS)
{
"name": "foo/bar",
"license": "proprietary",
"type": "project",
"autoload": {
"psr-4": {
"": "src/"
},
"classmap": [
"app/AppKernel.php",
"app/AppCache.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"require": {
"php": "^7.0",
"symfony/symfony": "3.2.*",
"doctrine/orm": "^2.5",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.3",
"symfony/swiftmailer-bundle": "^2.3",
"symfony/monolog-bundle": "^2.8",
"sensio/distribution-bundle": "^5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "^2.0",
"friendsofsymfony/user-bundle": "~2.0@dev",
"symfony/assetic-bundle": "^2.7",
"liip/imagine-bundle": "^1.4",
"doctrine/mongodb-odm": "^1.1",
"doctrine/mongodb-odm-bundle": "^3.1",
"guzzlehttp/guzzle": "~6.0",
"querypath/QueryPath": ">=3.0.0",
"alcaeus/mongo-php-adapter": "^1.0",
"ext-mongo": "*"
},
"require-dev": {
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^2.7"
},
"scripts": {
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
]
},
"extra": {
"symfony-app-dir": "app",
"symfony-bin-dir": "bin",
"symfony-var-dir": "var",
"symfony-web-dir": "web",
"symfony-tests-dir": "tests",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
}
}
}
【问题讨论】:
-
阅读消息。这就是它们的生成目的。 String 现在是 PHP7 中的一个受人尊敬的作品
-
是的,我知道这条消息。问题在于供应商包的版本错误,而不是我编写的代码,我的注释已更新为使用 Field(type="string") 我不知道为什么我的供应商包没有更新使用字段?
标签: mongodb symfony php-7 doctrine-odm