我已經安裝FOS user bundle
來管理登錄&註冊功能,但是當我嘗試註冊新用戶時,我收到以下錯誤:FOS用戶包註冊「實體的類型實體用戶缺少一個分配的ID字段'ID'
Entity of type ****\****\Entity\User is missing an assigned ID for field 'id'.
The identifier generation strategy for this entity requires the ID field to be
populated before EntityManager#persist() is called. If you want automatically
generated identifiers instead you need to adjust the metadata mapping accordingly.
這是我的user.php的類:
<?php
// src/Acme/UserBundle/Entity/User.php
namespace ***\***\Entity;
use FOS\UserBundle\Model\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")
*/
protected $id;
,這是我User.orm.yml:
****\****\Entity\User:
type: entity
table: fos_user
fields:
id:
id:
type: integer
generator:
strategy: AUTO
我知道這個問題出現在堅持一個新用戶的數據時,但我不知道如何讓Symfony
生成這個id
字段。 謝謝!
好,我刪除'generator'關鍵,但如果我也刪除'yml'設置文件,我會收到一個錯誤@鮑爾泰克 – PaulBST
前'strategy'關鍵 – bartek
'場加4位: ID: ID: 類型:整數 策略:AUTO' – PaulBST