我在我的Symfony 2.7項目中使用了FOSUserBundle
。在composer.json
文件中,要求被定義爲"friendsofsymfony/user-bundle" : "[email protected]"
。當前版本/提交45d6f40(11/03/2015)已安裝。字段'usernameCanonical'沒有被Doctrine映射,所以無法驗證唯一性
使用後composer update
最新版本7abb0ff已安裝。在此之後,我在嘗試創建新用戶時,以下異常:
字段「usernameCanonical」不被教條映射,所以它不能被驗證的唯一性
搜索該解決方案問題引發了處理相同例外的舊問題(here和here)。但是,我無法解決這些問題中討論的解決方案的問題。
Issue 1565建議使用FOS\UserBundle\Entity\User as BaseUser;
而不是FOS\UserBundle\Model\User as BaseUser;
。但是這個解決方案似乎對於2.x版本不是有效的。 2.x文檔說你應該從FOS\UserBundle\Model\User
擴展,這是有道理的,因爲沒有FOS\UserBundle\Entity\...
類了。
我的User類是這樣的:
namespace AppBundle\Entity;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* This class represents the User entity and extends the FOSBundle base user
* Entity class to be able to use FOSUserBundle to manage the application users.
*
* @ORM\Entity(repositoryClass="AppBundle\Entity\UserRepository")
* @ORM\Table(name="app_user") *
* @ORM\HasLifecycleCallbacks()
*/
class User extends BaseUser {
...
}
在Issue 1638的解決方案是在學說配置中使用auto_mapping
。我已經做到了。
因此,現有的解決方案都不適用於我。此問題的其他所有現有問題都很舊。
當然,我可以簡單地降級到版本/提交45d6f40。不過,我寧願解決問題,而不是忽略它:-)
任何其他的想法我可以解決這個問題?
PS:這是我的composer show -i
輸出:
doctrine/annotations v1.2.7 Docblock Annotations Parser
doctrine/cache v1.6.0 Caching library offering an object-oriented API for many cache backends
doctrine/collections v1.3.0 Collections Abstraction library
doctrine/common v2.6.1 Common Library for Doctrine projects
doctrine/dbal v2.4.5 Database Abstraction Layer
doctrine/doctrine-bundle v1.2.0 Symfony DoctrineBundle
doctrine/inflector v1.0.1 Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator 1.0.5 A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer v1.0.1 Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
doctrine/orm v2.4.8 Object-Relational-Mapper for PHP
friendsofsymfony/http-cache 1.4.0 Tools to manage cache invalidation
friendsofsymfony/http-cache-bundle 1.3.4 Set path based HTTP cache headers and send invalidation requests to your HTTP cache
friendsofsymfony/rest-bundle 1.4.2 This Bundle provides various tools to rapidly develop RESTful API's with Symfony2
friendsofsymfony/user-bundle dev-master 7abb0ff Symfony FOSUserBundle
gremo/buzz-bundle v1.1.0 Symfony Bundle for using the lightweight Buzz HTTP client.
guzzle/guzzle v3.9.3 PHP HTTP client. This library is deprecated in favor of https://packagist.org/packages/guzzlehttp/guzzle
jdorn/sql-formatter v1.2.17 a PHP SQL highlighting library
jms/metadata 1.5.1 Class/method/property metadata management in PHP
jms/parser-lib 1.0.0 A library for easily creating recursive-descent parsers.
jms/serializer 1.3.1 Library for (de-)serializing data of any complexity; supports XML, JSON, and YAML.
jms/serializer-bundle 1.1.0 Allows you to easily serialize, and deserialize data of any complexity
kriswallsmith/assetic v1.3.2 Asset Management for PHP
kriswallsmith/buzz v0.15 Lightweight HTTP client
leafo/scssphp v0.6.6 scssphp is a compiler for SCSS written in PHP.
moontoast/math 1.1.0 A mathematics library, providing functionality for large numbers
paragonie/random_compat v2.0.2 PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
phpcollection/phpcollection 0.5.0 General-Purpose Collection Library for PHP
phpoption/phpoption 1.5.0 Option Type for PHP
psr/log 1.0.0 Common interface for logging libraries
sensio/distribution-bundle v2.3.22 The base bundle for the Symfony Distributions
sensio/framework-extra-bundle v2.3.4 This bundle provides a way to configure your controllers with annotations
sensio/generator-bundle v2.3.5 This bundle generates code for you
swiftmailer/swiftmailer v5.4.3 Swiftmailer, free feature-rich PHP mailer
symfony/assetic-bundle v2.7.1 Integrates Assetic into Symfony2
symfony/monolog-bundle v2.8.2 Symfony MonologBundle
symfony/swiftmailer-bundle v2.3.11 Symfony SwiftmailerBundle
symfony/symfony v2.7.7 The Symfony PHP framework
tfox/mpdf-port-bundle 1.3.1 A wrapper for mPDF class which allows to use mPDF in Symfony2 projects
twig/extensions v1.0.1 Common additional features for Twig that do not directly belong in core
twig/twig v1.25.0 Twig, the flexible, fast, and secure template language for PHP
willdurand/jsonp-callback-validator v1.1.0 JSONP callback validator.
willdurand/negotiation 1.5.0 Content Negotiation tools for PHP provided as a standalone library.