2017-02-07 4 views
-1

PHP 5.5からPHP 7.0へのアップグレード中に、Symfonyプロジェクトに問題が発生しました。Doctrine ODM - PHP7 - クラス名としてInt/Stringを使用できません

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  

問題が最も可能性の高い要件が正しい教義/ MongoDBのをインストールから作曲の更新を妨げているcomposer.json

での設定の問題に関連している:?次の例外が発生しかし

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": "[email protected]", 
      "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" 
      } 
     } 
    } 
+0

メッセージを読んでください。それが何のために生成されるか。 ___StringはPHP7___のリバースされた作品になりました – RiggsFolly

+0

はい私はこのメッセージを知っています。問題はベンダーパッケージが間違ったバージョンで、私が書いたコードではなく、注釈がフィールド(type = "string")を使用するように更新されていることです。フィールドを使用するには? – lookbadgers

答えて

1

は、バンドル内の文書はまだ注釈参照を持っていたが判明します。

は、次のいずれかのコードベースを検索:

\String 
\Int 
\Bool 
\Float 

とで置き換える:

\Field(type="string") 
\Field(type="int") 
\Field(type="bool") 
\Field(type="float") 

私のコードでは別名

use Doctrine\ODM\MongoDB\Mapping\Annotations AS MongoDB; 

を注意してください私は、検索を接頭辞MongoDB、すなわちMongoDB\Int became MongoDB\Field(type="int")

関連する問題