1.annotation定义路由

@Route("/**",defaults={"name":"world"},requirements={"name"="\s"})  参数要用双引号,不能用单引号。

2.执行命令php app/console doctrine:generate:entities CaiganBundle  报错的原因是 Entity类中ORM后面不能用“/”,要用“\”;并且括号中的参数一定要用双引号,不能用单引号https://stackoverflow.com/questions/26803213/the-annotation-doctrine-orm-mapping-in-class-xx-does-not-exist-or-cannot-be-lo

<?php
namespace CaiganBundle\Entity;
use Doctrine\ORM\Mapping as ORM; /**
* Class User
* @package CaiganBundle\Entity
* @ORM\Entity(repositoryClass="UserRepository")
* @ORM\Table(name="user")
*/
class User
{
/**
* @ORM\Id //不能用“/”,要用“\”
* @ORM\Column(type="integer",length=10)//双引号
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string",length=32)
*/
protected $username;
/**
* @ORM\Column(type="string",length=32)
*/
protected $password;
}
04-20 15:38