生成getter和setter时不包含任何映射实体

时间:2013-11-12 03:44:55

标签: symfony doctrine

我想用one to one

在symfony 2中创建doctrine关系

这是我的实体类

<?php

namespace Travel\HomeBundle\Entity;

use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="fos_user")
 */
class User extends BaseUser
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /** @ORM\Column(name="facebook_id", type="string", length=255, nullable=true) */
    protected $facebook_id;

    /** @ORM\Column(name="facebook_access_token", type="string", length=255, nullable=true) */
    protected $facebook_access_token;



     /** 

     @ORM\Column(name="travel_id", type="string", length=255, nullable=true)
     @ORM\OneToOne(targetEntity="Travel\HomeBundle\Entity\Client") 
     @ORM\JoinColumn(name="travel_id", referencedColumnName="id") 

     */

    protected $travel_id;


    /** 

      @ORM\Column(name="travel_access_token", type="string", length=255, nullable=true) 
      @ORM\OneToOne(targetEntity="Travel\HomeBundle\Entity\Client")
      @ORM\JoinColumn(name="travel_access_token", referencedColumnName="secret")

     */

    protected $travel_access_token;




    public function __construct()
    {
        parent::__construct();
        // your own logic
    }


}

?>
当我运行以下命令生成getter和setter方法

时更新模式后

php app/console doctrine:generate:entities Travel/HomeBundle/Entity/User.php

我正在关注Runtime Error

 Namespace "Travel\HomeBundle\Entity\User.php" does not contain any mapped  
   entities.

1 个答案:

答案 0 :(得分:4)

doctrine:generate:entities不接受文件扩展名。只需删除.php

即可

以下是doctrine:generate:entities的可接受参数示例:

php app/console doctrine:generate:entities Travel/HomeBundle/Entity/User

或者

php app/console doctrine:generate:entities TravelHomeBundle:User