我按照食谱中描述的步骤进行操作。但是当我跑步doctrine:mapping:info
或doctrine:generate:entities
学说忽略我的文件时。
这是代码,也许有人有建议。
自动加载.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;
作曲家.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",
配置.yml:
doctrine_mongodb:
connections:
default:
server: mongodb://localhost:27017
options: {}
default_database: test_database
document_managers:
default:
auto_mapping: true
实体:
<?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;
}