带有symfony 3.4.4的FOSUserBundle 2.0:无法识别的字段:usernameCanonical

时间:2018-02-09 15:11:19

标签: symfony fosuserbundle

我只是根据文档设置了FOSUserBundle,所有字段都已在数据库中创建(见下文)。

现在,当我想注册第一个用户时,我收到此错误消息:

无法识别的字段:usernameCanonical

我做错了什么?

这是我的设置(Windows 7上的php 7.2.1):

  

php bin / console doctrine:mapping:info

Found .. mapped entries:
...
[OK]  App\Entity\User
...
[OK]  FOS\UserBundle\Model\Group
[OK]  FOS\UserBundle\Model\User
  

php bin / console doctrine:schema:validate

[Mapping]  OK - The mapping files are correct.
[Database] OK - The database schema is in sync with the mapping files.

user.php的:

<php
namespace App\Entity;

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

/**
 * @ORM\Entity(repositoryClass="App\Repository\FeeRepository")
 * @ORM\Table(name="fos_user")
 * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=true, hardDelete=true)
 */
class User extends BaseUser {
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     * 
     * @var int
     */
    protected $id;

    /**
     * @ORM\Column(type="datetime", nullable=true)
     * @Gedmo\Timestampable(on="create")
     * 
     * @var \DateTime
     */
    private $created;

    /**
     * @ORM\Column(type="datetime", nullable=true)
     * @Gedmo\Timestampable(on="update")
     * 
     * @var \DateTime
     */
    private $modified;

    /**
     * @ORM\Column(type="datetime", nullable=true)
     * 
     * @var \DateTime
     */
    private $deletedAt;

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

//    getters and setters for created, modified and deletedAt

}

fos_user.yaml:

fos_user:
    db_driver: orm 
    firewall_name: main
    user_class: App\Entity\User
    from_email:
        address: user@example.com
        sender_name: "Sender Name"
    service:
        mailer: 'fos_user.mailer.noop'

doctrine.yaml:

doctrine:
    dbal:
    ...
    orm:
        auto_generate_proxy_classes: '%kernel.debug%'
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true
        mappings:
            App:
                is_bundle: false
                type: annotation
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'App\Entity'
                alias: App

            FOSUserBundle: ~

数据库-表:

CREATE TABLE `fos_user` (
  `id` int(11) NOT NULL,
  `username` varchar(180) COLLATE utf8mb4_unicode_ci NOT NULL,
  `username_canonical` varchar(180) COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(180) COLLATE utf8mb4_unicode_ci NOT NULL,
  `email_canonical` varchar(180) COLLATE utf8mb4_unicode_ci NOT NULL,
  `enabled` tinyint(1) NOT NULL,
  `salt` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `last_login` datetime DEFAULT NULL,
  `confirmation_token` varchar(180) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `password_requested_at` datetime DEFAULT NULL,
  `roles` longtext COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '(DC2Type:array)',
  `created` datetime DEFAULT NULL,
  `modified` datetime DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

欣赏任何提示,以及尝试的内容

谢谢!

0 个答案:

没有答案