1

我尝试通过 sonatauserbundle 将 FOSUserBundle 与 symfony2.2 中的 SonataAdminBundle集成,但我想打开这个 URL http://dev.test.com/app_dev.php/register它说

“在类 'Application\Sonata\UserBundle\Document\User' 中找不到字段 'username' 的映射。”

我想登录管理面板,但我的测试管理员用户无法登录。

这是我的 composer.js

"require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.2.*",
        "doctrine/orm": "~2.2,>=2.2.3",
        "doctrine/doctrine-bundle": "1.2.*",
        "twig/extensions": "1.0.*",
        "symfony/assetic-bundle": "2.1.*",
        "symfony/swiftmailer-bundle": "2.2.*",
        "symfony/monolog-bundle": "2.2.*",
        "sensio/distribution-bundle": "2.2.*",
        "sensio/framework-extra-bundle": "2.2.*",
        "sensio/generator-bundle": "2.2.*",
        "jms/security-extra-bundle": "1.4.*",
        "jms/di-extra-bundle": "1.3.*",
        "doctrine/mongodb-odm": "1.0.*@dev",
        "doctrine/mongodb-odm-bundle": "3.0.*@dev",
        "friendsofsymfony/user-bundle": "*",
        "sonata-project/easy-extends-bundle" : "dev-master",
        "sonata-project/cache-bundle": "dev-master",
        "sonata-project/jquery-bundle": "1.8.x-dev",
        "sonata-project/exporter": "1.2.1",
        "sonata-project/block-bundle": "dev-master",
        "sonata-project/user-bundle": "dev-master",
        "sonata-project/admin-bundle": "dev-master",
        "sonata-project/doctrine-mongodb-admin-bundle": "dev-master",
        "knplabs/knp-menu-bundle": "1.1.x-dev"
    }

这是我的 config.yml

# Mongodb Configuration
doctrine_mongodb:
    connections:
        default:
            server: mongodb://localhost:27017
            options: {}
    default_database: test
    document_managers:
        default:
            auto_mapping: true

#FOSUserBundle Configuration
# fos_user:
#     db_driver: mongodb # other valid values are 'mongodb', 'couchdb' and 'propel'
#     firewall_name: main
#     user_class: Acme\UserBundle\Entity\User

sonata_block:
    default_contexts: [cms]
    blocks:
        sonata.admin.block.admin_list:
            contexts:   [admin]

        sonata.block.service.text:
        sonata.block.service.rss:

sonata_admin:
    title:      Admin Panel
    templates:
        ## default global templates
        layout:  SonataAdminBundle::standard_layout.html.twig
        ajax:    SonataAdminBundle::ajax_layout.html.twig

        ## default actions templates, should extend a global templates
        list:    SonataAdminBundle:CRUD:list.html.twig
        show:    SonataAdminBundle:CRUD:show.html.twig
        edit:    SonataAdminBundle:CRUD:edit.html.twig

fos_user:
    db_driver: mongodb
    firewall_name: main
    user_class: Application\Sonata\UserBundle\Document\User

sonata_user:
    security_acl: false
    manager_type: mongodb

# Swiftmailer Configuration
swiftmailer:
    transport: %mailer_transport%
    host:      %mailer_host%
    username:  %mailer_user%
    password:  %mailer_password%
    spool:     { type: memory }

我开发使用symfony2.2和mongodb,如果你知道请帮助我,非常感谢!

4

1 回答 1

0

也许 Symfony 2 无法读取映射。

在您的 app/config/config.yml 中,您可以查找教义配置。

doctrine_mongodb:
    connections:
        default:
            server: mongodb://localhost:27017
            options: {}
    default_database: hello_%kernel.environment%
    document_managers:
        default:
            mappings:
                AcmeDemoBundle: ~

为映射部分添加捆绑包

我希望这有助于祝福

于 2013-08-16T17:43:28.380 回答