2

I followed the steps descriped in the cookbook. But when i run doctrine:mapping:info or doctrine:generate:entities doctrine ignores my file.

Here is the code, maybe someone has an advice.

autoload.php

use Doctrine\Common\Annotations\AnnotationRegistry;
use Composer\Autoload\ClassLoader;

/**
 * @var $loader ClassLoader
 */
$loader = require __DIR__.'/../vendor/autoload.php';

AnnotationRegistry::registerLoader(array($loader, 'loadClass'));

use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver;
AnnotationDriver::registerAnnotationClasses();

return $loader;

composer.json

"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/mongodb-odm": "1.0.*@dev",
"doctrine/mongodb-odm-bundle": "3.0.*@dev",
"doctrine/doctrine-bundle": "1.2.*",
"doctrine/doctrine-fixtures-bundle": "dev-master",
"doctrine/doctrine-migrations-bundle": "dev-master",

config.yml:

doctrine_mongodb:
    connections:
        default:
            server: mongodb://localhost:27017
            options: {}
    default_database: test_database
    document_managers:
        default:
            auto_mapping: true

entity:

<?php
// src/Acme/StoreBundle/Document/Product.php
namespace Anchorbrands\Bundle\LandingpageBundle\Entity;

use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;

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

/**
* @MongoDB\String
*/
protected $name;

/**
* @MongoDB\Float
*/
protected $price;
}
0

1 Answer 1

3

wrong namespace/folder :)

namespace Anchorbrands\Bundle\LandingpageBundle\Entity;

should be

namespace Anchorbrands\Bundle\LandingpageBundle\Document;

The documents usually live in the Document folder.

Entity folder/namespace is for ORM not ODM.

Have a look at the documentation here.

Wrong command

for mongodb / doctrine odm you need to use ...

app/console doctrine:mongodb:generate:documents AnchorbrandsLandingpageBundle

... while doctrine:generate:entities is for doctrine orm.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.