I am using Symfony 2.1 RC1
and the FOSUserbundle
on a Windows server running PHP 5.3.13.
我在运行PHP 5.3.13的Windows服务器上使用Symfony 2.1 RC1和FOSUserbundle。
I have followed the instructions here but Doctrine doesn't create fields in the database for the properties inherited from the base FOS User class (only the fields from my class).
我已经遵循了这里的说明,但是Doctrine没有为从base FOS用户类继承的属性在数据库中创建字段(只有来自我的类的字段)。
Trying to login using the FOS login form produces the error:
尝试使用FOS登录表单登录会产生以下错误:
Unrecognized field: usernameCanonical
I have the following Doctrine configuration:
我有以下学说配置:
# Doctrine Configuration
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
And the FOSUserBundle config looks like:
FOSUserBundle配置如下:
fos_user:
db_driver: orm
firewall_name: main
user_class: SP\PickList\UserBundle\Entity\User
My User entity:
我的用户实体:
namespace SP\PickList\UserBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Document\User as BaseUser;
/**
* SP\PickList\UserBundle\Entity\User
*
* @ORM\Table(name="fos_user")
* @ORM\Entity
*/
class User extends BaseUser
{
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
}
Thanks for any help,
感谢任何帮助,
James Bench
詹姆斯板凳
3 个解决方案
#1
17
It seems you are mixing instructions for ORM and ODM, if you use Doctrine ORM as per your config, your User class must extend FOS\UserBundle\Entity\User
, try to change the use
statement as
似乎您正在混合ORM和ODM的指令,如果您按照配置使用Doctrine ORM,那么您的用户类必须扩展FOS\UserBundle\Entity\User用户,尝试将use语句改为
use FOS\UserBundle\Entity\User as BaseUser;
#2
5
To save someone some time. Don't forget if you are not using auto_mapping in your ORM config in config.yml you need to add 'FOSUserBundle: ~' to the mapping.
为某人节省时间。如果在配置中没有在ORM配置中使用auto_mapping,请不要忘记。yml您需要在映射中添加“FOSUserBundle: ~”。
#3
1
Also you must specify which entity user class you'll use in app/config/config.yml
还必须指定在app/config/config.yml中使用哪个实体用户类
# FOS
fos-user:
db_driver: orm
firewall_name: main #optional
user_class: FOS\UserBundle\Entity\User
#1
17
It seems you are mixing instructions for ORM and ODM, if you use Doctrine ORM as per your config, your User class must extend FOS\UserBundle\Entity\User
, try to change the use
statement as
似乎您正在混合ORM和ODM的指令,如果您按照配置使用Doctrine ORM,那么您的用户类必须扩展FOS\UserBundle\Entity\User用户,尝试将use语句改为
use FOS\UserBundle\Entity\User as BaseUser;
#2
5
To save someone some time. Don't forget if you are not using auto_mapping in your ORM config in config.yml you need to add 'FOSUserBundle: ~' to the mapping.
为某人节省时间。如果在配置中没有在ORM配置中使用auto_mapping,请不要忘记。yml您需要在映射中添加“FOSUserBundle: ~”。
#3
1
Also you must specify which entity user class you'll use in app/config/config.yml
还必须指定在app/config/config.yml中使用哪个实体用户类
# FOS
fos-user:
db_driver: orm
firewall_name: main #optional
user_class: FOS\UserBundle\Entity\User