首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PHP致命错误:找不到类'Doctrine\Common\Persistence\Mapping\Driver\FileDriver‘

PHP致命错误:找不到类'Doctrine\Common\Persistence\Mapping\Driver\FileDriver‘
EN

Stack Overflow用户
提问于 2012-07-30 08:00:13
回答 3查看 2.7K关注 0票数 0

我一步一步地按照http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html上的说明操作,但是当我尝试这样做时,会运行一个Mongo服务器:

代码语言:javascript
复制
php app/console generate:bundle --namespace=Acme/StoreBundle

我得到了

代码语言:javascript
复制
Class 'Doctrine\Common\Persistence\Mapping\Driver\FileDriver' not found in /Users/username/Sites/myapp/vendor/doctrine-mongodb-odm/lib/Doctrine/ODM/MongoDB/Mapping/Driver/XmlDriver.php on line 37

我在想,我的parameters.ini文件可能出了什么问题,它仍然提到了MYSQL,但是上面的链接没有提到任何关于这方面的内容:

代码语言:javascript
复制
[parameters]
    database_driver="pdo_mysql"
    database_host="localhost"
    database_port=""
    database_name="somedb"
    database_user="root"
    database_password="mypassword"
    mailer_transport="smtp"
    mailer_host="localhost"
    mailer_user=""
    mailer_password=""
    locale="en"
    secret="093faacf47bcdcdcdcdcdc9d152fc8b"

我做错了什么?

更新:

我下载了Doctrine Common,下面是我的registerNameSpaces函数:

代码语言:javascript
复制
$loader->registerNamespaces(array(
    'Symfony'          => array(__DIR__.'/../vendor/symfony/src', __DIR__.'/../vendor/bundles'),
    'Sensio'           => __DIR__.'/../vendor/bundles',
    'JMS'              => __DIR__.'/../vendor/bundles',
    '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',
    'Monolog'          => __DIR__.'/../vendor/monolog/src',
    'Assetic'          => __DIR__.'/../vendor/assetic/src',
    'Metadata'         => __DIR__.'/../vendor/metadata/src',
    'FOS'              => __DIR__.'/../vendor/bundles',
    'FOS\\Rest'        => __DIR__.'/../vendor/fos',
    'JMS'              => __DIR__.'/../vendor/bundles',
));

我的deps文件:

代码语言:javascript
复制
[symfony]
    git=http://github.com/symfony/symfony.git
    version=origin/2.0

[twig]
    git=http://github.com/fabpot/Twig.git
    version=v1.8.2

[monolog]
    git=http://github.com/Seldaek/monolog.git
    version=1.0.2

[doctrine-common]
    git=http://github.com/doctrine/common.git
    version=2.1.4

[doctrine-dbal]
    git=http://github.com/doctrine/dbal.git
    version=2.1.7

[doctrine]
    git=http://github.com/doctrine/doctrine2.git
    version=2.1.7

[swiftmailer]
    git=http://github.com/swiftmailer/swiftmailer.git
    version=v4.2.0

[assetic]
    git=http://github.com/kriswallsmith/assetic.git
    version=v1.0.3

[twig-extensions]
    git=http://github.com/fabpot/Twig-extensions.git

[metadata]
    git=http://github.com/schmittjoh/metadata.git
    version=1.0.0

[SensioFrameworkExtraBundle]
    git=http://github.com/sensio/SensioFrameworkExtraBundle.git
    target=/bundles/Sensio/Bundle/FrameworkExtraBundle
    version=origin/2.0

[JMSSecurityExtraBundle]
    git=http://github.com/schmittjoh/JMSSecurityExtraBundle.git
    target=/bundles/JMS/SecurityExtraBundle
    version=origin/1.0.x

[SensioDistributionBundle]
    git=http://github.com/sensio/SensioDistributionBundle.git
    target=/bundles/Sensio/Bundle/DistributionBundle
    version=origin/2.0

[SensioGeneratorBundle]
    git=http://github.com/sensio/SensioGeneratorBundle.git
    target=/bundles/Sensio/Bundle/GeneratorBundle
    version=origin/2.0

[AsseticBundle]
    git=http://github.com/symfony/AsseticBundle.git
    target=/bundles/Symfony/Bundle/AsseticBundle
    version=origin/2.0


[FOSUserBundle]
    git=git://github.com/FriendsOfSymfony/FOSUserBundle.git
    target=bundles/FOS/UserBundle
    version=1.2.0

[FOSRest]
    git=git://github.com/FriendsOfSymfony/FOSRest.git
    target=fos/FOS/Rest

[FOSRestBundle]
    git=git://github.com/FriendsOfSymfony/FOSRestBundle.git
    target=bundles/FOS/RestBundle

[JMSSerializerBundle]
    git=git://github.com/schmittjoh/JMSSerializerBundle.git
    target=bundles/JMS/SerializerBundle


[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/doctrine/DoctrineMongoDBBundle.git
    target=/bundles/Symfony/Bundle/DoctrineMongoDBBundle
    version=origin/2.0

我在映射下也看不到驱动程序文件夹。我已经做了一个php bin/vendors安装--reinstall bu,即使这样也没有帮助。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-07-30 12:14:52

您必须更新这三个: DBAL、Common和ORM。这三个版本已经同时发布了。因此,您应该对3使用版本2.2。

这里是博客帖子http://www.doctrine-project.org/blog/doctrine-2-2-final.html

希望这对我有帮助,它对我很有效。

票数 2
EN

Stack Overflow用户

发布于 2012-07-30 09:58:32

Doctrine MongoDB ODM最近进行了重构,以利用Doctrine Common的映射API,该映射API存在于版本2.2+中(参见PR的#350#370)。反过来,捆绑包的2.0和主分支都进行了更新(PR #124)。

根据您的deps文件,您使用的是Doctrine Common 2.1.x,它不包含所需的类。您可以将Common提升到2.2,这应该与Symfony 2.0兼容,或者在合并这些PR之前将ODM和捆绑包锁定到更早的提交散列。即使您没有使用Composer,检查每个存储库中的composer.json文件也是跟踪这些依赖关系的好方法。希望我们很快就能在Mongo ODM存储库上添加标签,这将在未来缓解这一令人头疼的问题。

票数 1
EN

Stack Overflow用户

发布于 2012-07-30 08:24:58

您可能没有安装Doctrine Common,或者您没有在自动加载器中注册Doctrine Common。安装它(链接:https://github.com/doctrine/common)或重新下载sf2标准版。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11714006

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档