我有问题:
MappingException:类'Acme \ UserBundle \ Entity \ User'不是 在链中找到配置的命名空间FOS \ UserBundle \ Entity, FOS \ UserBundle \模型
我的文件Acme \ UserBundle \ Entity \ User
<?php
// src/Acme/UserBundle/Entity/User.php
namespace Acme\UserBundle\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")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
public function __construct()
{
parent::__construct();
// your own logic
}
}
答案 0 :(得分:1)
可能你缺少配置文件。
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Acme\UserBundle\Entity\User
干杯!
答案 1 :(得分:0)
还要确保config.yml中的学说配置与此类似:
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
(值得注意的是auto_mapping:true和auto_generate_proxy_classes ......)