Symfony 2 CRUD命令的致命错误

时间:2014-05-14 21:34:37

标签: crud fatal-error

祝福!

执行CRUD命令时出错,我在控制台中看到此错误。

Fatal error: Class 'Doctrine\Bundle\DoctrineBundle\Mapping\MetadataFactory'
not found in [route-to-project]\vendor\sensio\generator-bundle\Sensio\Bundle
\GeneratorBundle\Command\GenerateDoctrineCommand.php on line 36

searching the web我发现升级Doctrine与sensiogenerator捆绑不兼容,应该回滚到以前的版本。

但我不能这样做,因为我有几个安装的软件包与早期版本的学说不兼容。

我有一个解决方案,或者我必须手动创建控制器?

谢谢!

这是我的composer.json

{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
    "psr-0": { "": "src/" }
},
"require": {
    "php": ">=5.3.3",
    "symfony/symfony": "2.4.*",
    "doctrine/orm": "2.*",
    "doctrine/doctrine-bundle": "1.3.*@dev",
    "twig/extensions": "1.*",
    "symfony/assetic-bundle": "2.3.*",
    "symfony/swiftmailer-bundle": "2.3.*",
    "symfony/monolog-bundle": "2.3.*",
    "sensio/distribution-bundle": "2.3.*",
    "sensio/framework-extra-bundle": "2.3.*",
    "sensio/generator-bundle": "2.3.*",
    "incenteev/composer-parameter-handler": "~2.0",
    "friendsofsymfony/user-bundle": "~1.3",        
    "sonata-project/cache-bundle" : "dev-master",
    "sonata-project/intl-bundle" : "dev-master",
    "sonata-project/admin-bundle": "~2.1",
    "sonata-project/doctrine-orm-admin-bundle": "2.*",
    "sonata-project/easy-extends-bundle": "2.*",
    "sonata-project/user-bundle": "2.2.*@dev",
    "sonata-project/block-bundle": "~2.2,>=2.2.7",
    "sonata-project/core-bundle": "~2.2@dev",        
    "knplabs/knp-menu-bundle": ">=1.1.0,<3.0.0",
    "knplabs/knp-menu": ">=1.1.0,<3.0.0",
    "sonata-project/jquery-bundle": "1.8.*",
    "sonata-project/exporter": "1.3.3",

    "whiteoctober/tcpdf-bundle":"dev-master",
    "knplabs/knp-snappy-bundle": "*"

},
"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"
    ],
    "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"
    ]
},
"config": {
    "bin-dir": "bin"
},
"minimum-stability": "stable",
"extra": {
    "symfony-app-dir": "app",
    "symfony-web-dir": "web",
    "incenteev-parameters": {
        "file": "app/config/parameters.yml"
    },
    "branch-alias": {
        "dev-master": "2.3-dev"
    }
}
}

2 个答案:

答案 0 :(得分:1)

我找到了解决方案!只需在vendor \ doctrine \ doctrine-bundle \ Doctrine \ DoctrineBundle \ Mapping中创建MetadataFactory.php文件,然后在MetadataFactory类中创建

here the file

答案 1 :(得分:1)

更好的解决方案

任何使用Symfony 2.7或更低版​​本的人都可能会遇到此问题。

Here is the commit where the problem was fixed

您可以将其直接修补到您的代码库,但修改核心供应商文件会使编写器变得多余。

更好的解决方案是将SensioGeneratorBundle升级为v2.5,这似乎与Symfony v2.7兼容

composer.json中更改此内容:"sensio/generator-bundle": "2.5.*"

然后运行composer update被警告 - 这将更新您的作曲家文件中的所有内容,这可能是不可取的。

替代解决方案

仅更新单个包

composer require sensio/generator-bundle:2.5.3