Reputation: 125
Good Mourning!
I have an error while performing the CRUD command, I see this error in the console.
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 I found that the upgrade Doctrine is not compatible with the bundle of sensiogenerator and should rollback to a previous version.
But I can not do it because I have several installed bundles that are not compatible with an early version of doctrine.
I hava a solution or I have to create the controllers manually?
Thank you!
this is my 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"
}
}
}
Upvotes: 2
Views: 456
Reputation: 421
Better Solution
Anyone using Symfony 2.7 or lower might run into this.
Here is the commit where the problem was fixed
You could patch this directly to your codebase, but modifying core vendor files makes composer redundant.
A better solution is to upgrade the SensioGeneratorBundle
to v2.5
, which appears to be compatible with Symfony v2.7
In composer.json
change this: "sensio/generator-bundle": "2.5.*"
Then run composer update
(be warned - this will update everything in your composer file, which may not be desirable.)
Alternative Solution
Only update a single package
composer require sensio/generator-bundle:2.5.3
Upvotes: 1
Reputation: 125
I found the solution! Just create a MetadataFactory.php file in vendor\doctrine\doctrine-bundle\Doctrine\DoctrineBundle\Mapping whit the MetadataFactory class
Upvotes: 1