错误:doctrine.mongodb:generate:document没有找到与Symfony3捆绑的Bundle

时间:2016-09-11 09:45:07

标签: symfony doctrine-mongodb

错误:doctrine.mongodb:generate:document未找到Symfony3的捆绑包。

C:\ Bitnami \ wampstack-5.6.20-0 \的Apache2 \ htdocs中\符号\ patmonS1> php bin/console doctrine:mongodb:generate:document PatmonBundle:Product

PHP Warning:  Module 'mongo' already loaded in Unknown on line 0
  [Symfony\Component\Console\Exception\RuntimeException]
  The "--filter" option does not exist.

config.tml

doctrine_mongodb:
    connections:
        default:
            server: "%mongodb_server%"
            options: {}
    default_database: hello_%kernel.environment%
    document_managers:
        default:
            mappings:
                PatmonBundle: ~
            #filters:
            #    filter-name:
            #        class: Class\Example\Filter\ODM\ExampleFilter
            #        enabled: true
            metadata_cache_driver: array # array, apc, xcache, memcache

C:\ Bitnami \ wampstack-5.6.20-0 \的Apache2 \ htdocs中\符号\ patmonS1 \应用\配置\ services.yml 服务:

mongo_client:
    class: MongoClient
    # if using a username and password
    arguments: ['mongodb://%mongodb_username%:%mongodb_password%@%mongodb_host%:27017']

session.handler.mongo:
    class: Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler
    arguments: ['@mongo_client', '%mongo.session.options%']

C:\ Bitnami \ wampstack-5.6.20-0 \的Apache2 \ htdocs中\符号\ patmonS1 \应用\配置\ parameters.yml

parameters:
    mongodb_server: mongodb://localhost:27017
    mongodb_username: username
    mongodb_password: password
    mongodb_host: localhost
    mongo.session.options:
        db_name: mdb_patmonS1
        collection: session

C:\ Bitnami \ wampstack-5.6.20-0 \的Apache2 \ htdocs中\符号\ patmonS1 \ SRC \专利\ monBundle \文献\ Product.php

<?php

namespace Pat\monBundle\Document;

// http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html
// http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html#cookbook-mongodb-field-types
// http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/basic-mapping.html

use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
//use Doctrine\ODM\MongoDB\Mapping\Annotations\Document; with annotation @Document

/**
 * @MongoDB\Document
 */
class Product
{
    /**
     * @MongoDB\Id
     */
    protected $id;

    /**
     * @MongoDB\Field(type="string")
     */
    protected $name;

    /**
     * @MongoDB\Field(type="float")
     */
    protected $price;
}

1 个答案:

答案 0 :(得分:0)

刚才意识到,mongodb中不存在这样的命令。我是mongodb的新手。不过,存在命令:

php bin / console doctrine:mongodb:generate:documents PatmonBundle

http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html

相关问题