首先必须有个合格的Entity 就是个设置映射关系的Entity类。
<?php
// src/jiaochangyun/cmsBundle/Entity/User.php
namespace jiaochangyun\cmsBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @author JiaoChangyun
*
*/
class User
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @orm\column(type="string", length="255")
*/
protected $name;
/**
* @ORM\Column(type="string")
*/
protected $age;
}
然后命令行 php app/console doctrine:generate:entities BundleName:EntityName 就可以