Php DoctrineMongoDBBundle在Symfony2中遇到致命错误
我按照这里的指示: 我安装了deps:Php DoctrineMongoDBBundle在Symfony2中遇到致命错误,php,mongodb,symfony,doctrine-orm,symfony-2.0,Php,Mongodb,Symfony,Doctrine Orm,Symfony 2.0,我按照这里的指示: 我安装了deps: #deps [doctrine-mongodb] git=http://github.com/doctrine/mongodb.git [doctrine-mongodb-odm] git=http://github.com/doctrine/mongodb-odm.git [DoctrineMongoDBBundle] git=http://github.com/symfony/DoctrineMongoDBBundle.g
#deps
[doctrine-mongodb]
git=http://github.com/doctrine/mongodb.git
[doctrine-mongodb-odm]
git=http://github.com/doctrine/mongodb-odm.git
[DoctrineMongoDBBundle]
git=http://github.com/symfony/DoctrineMongoDBBundle.git
target=/bundles/Symfony/Bundle/DoctrineMongoDBBundle
然后,$php bin/供应商是否安装了
我补充说:
# app/autoload.php
$loader->registerNamespaces(array(
// ....
'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
'Doctrine\\DBAL' => __DIR__.'/../vendor/doctrine-dbal/lib',
'Doctrine\\ODM\\MongoDB' => __DIR__.'/../vendor/doctrine-mongodb-odm/lib',
'Doctrine\\MongoDB' => __DIR__.'/../vendor/doctrine-mongodb/lib',
'Doctrine' => __DIR__.'/../vendor/doctrine/lib',
// ....
));
AnnotationRegistry::registerFile(
__DIR__.'/../vendor/doctrine/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'
);
AnnotationRegistry::registerFile(
__DIR__.'/../vendor/doctrine-mongodb-odm/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/DoctrineAnnotations.php'
);
我还补充说
# app/AppKernel.php
$bundles = array(
//....
new Symfony\Bundle\DoctrineMongoDBBundle\DoctrineMongoDBBundle(),
//....
);
我的条令配置如下所示:
# Doctrine Configuration
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
doctrine_mongodb:
connections:
default:
server: mongodb://localhost:27017
options:
connect: true
default_database: dbtest
document_managers:
default:
auto_mapping: true
但当我加载应用程序时,会出现以下错误:
Fatal error: Class 'Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension' not found in /Volumes/Master/SITES/example/vendor/bundles/Symfony/Bundle/DoctrineMongoDBBundle/DependencyInjection/DoctrineMongoDBExtension.php on line 31
Call Stack:
0.0002 643984 1. {main}() /Volumes/Master/SITES/example/web/app_dev.php:0
0.0175 5274704 2. Symfony\Component\HttpKernel\Kernel->handle() /Volumes/Master/SITES/example/web/app_dev.php:31
0.0176 5274800 3. Symfony\Component\HttpKernel\Kernel->boot() /Volumes/Master/SITES/example/vendor/symfony/src/Symfony/Component/HttpKernel/Kernel.php:168
0.0212 5592040 4. Symfony\Component\HttpKernel\Kernel->initializeContainer() /Volumes/Master/SITES/example/vendor/symfony/src/Symfony/Component/HttpKernel/Kernel.php:127
0.0232 5662744 5. Symfony\Component\HttpKernel\Kernel->buildContainer() /Volumes/Master/SITES/example/vendor/symfony/src/Symfony/Component/HttpKernel/Kernel.php:545
0.0430 8473952 6. Symfony\Bundle\DoctrineMongoDBBundle\DoctrineMongoDBBundle->getContainerExtension() /Volumes/Master/SITES/example/vendor/symfony/src/Symfony/Component/HttpKernel/Kernel.php:630
0.0430 8474568 7. Symfony\Component\ClassLoader\DebugUniversalClassLoader->loadClass() /Volumes/Master/SITES/example/vendor/symfony/src/Symfony/Component/ClassLoader/DebugUniversalClassLoader.php:0
0.0437 8623704 8. require('/Volumes/Master/SITES/example/vendor/bundles/Symfony/Bundle/DoctrineMongoDBBundle/DependencyInjection/DoctrineMongoDBExtension.php') /Volumes/Master/SITES/example/vendor/symfony/src/Symfony/Component/ClassLoader/DebugUniversalClassLoader.php:55
我的应用程序使用的是MySQL,但我想评估mongodb。尝试修复捆绑包的版本:
[DoctrineMongoDBBundle]
git=http://github.com/symfony/DoctrineMongoDBBundle.git
target=/bundles/Symfony/Bundle/DoctrineMongoDBBundle
version=v2.0.0
请记住始终使用
bin/vendors install
-而不是bin/vendors update
。当然,除非您自己开发Symfony。我已经使用这个捆绑包几个月了,在我运行bin/vendors install
更新捆绑包后,它今天停止工作。所以我认为开发人员改变了一些东西。因为我是master
,所以这只是时间问题。因此,我在捆绑包的回购协议中查找了一个标签并粘贴到它上。bin/vendors update
也可以用于冻结捆绑包版本,比如说发布应用程序。这真的很有帮助。我还需要为示例配置添加来自的配置。即使它是无法访问的数据库的无效配置。