fos 创建用户 Symfony

fos create user Symfony

所以我正在与 fosuser 合作! 我设法在 class

中添加了一些字段
<?php
namespace mynamespace;

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

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

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

    // Change the targetEntity path if you want to create the group

    /**
     * @ORM\ManyToMany(targetEntity="userBundle\Entity\Group")
     * @ORM\JoinTable(name="fos_user_user_group",
     *      joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
     *      inverseJoinColumns={@ORM\JoinColumn(name="group_id", referencedColumnName="id")}
     * )
     */
    protected $groups;

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

    /**
     * Get about
     *
     * @return String
     */
    public function getAbout()
    {
        return $this->about;
    }

    /**
     * Set about
     *
     * @param String $about
     * @return User
     */
    public function setAbout($about)
    {
        $this->about = $about;

        return $this;
    }
}

之后,我使用以下命令更新了数据库的架构

php bin/console doctrine:schema:update --force

问题是当我尝试使用命令行创建 fos:user 时出现此错误

An exception occurred while executing 'INSERT INTO fos_user (username, username_canonical, email, email_canonical, enabled, salt, password, last_login, confirmation_token, passw
  ord_requested_at, roles, about) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

而且我无法手动将值插入数据库,因为某些字段已加密,例如密码

我可以做什么来更新 fos:user:create 命令以便我可以填写 "about" 字段

谢谢

在您的构造中设置一个默认值,以便在插入数据库时​​没有空值:

public function __construct()
    {
        parent::__construct();
        $this->about = "default about value"; //<-- add this
        // your own logic
    }