【发布时间】:2016-04-04 12:53:43
【问题描述】:
我正在使用 Symfony2,当我尝试附加 FOSUserBundle 时,出现错误 (bin/控制台原则:schema:update --force)
//--------------------------------------------- ------------------Appkernel.php
public function registerBundles()
{
$bundles = [
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new AppBundle\AppBundle(),
new main\kipeoBundle\kipeoBundle(),
new FOS\UserBundle\FOSUserBundle(),
];
//--------------------------------------------- --------app/config/config.yml
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: main\kipeoBundle\Entity\User
//----------------------------------------src-main>kipeoBundle >实体>User.php
namespace main\kipeoBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Model\User as BaseUser;
/**
* @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
}
}
//--------------------------------------------- --------app/config/routing.yml
fos_user:
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
【问题讨论】:
-
你的包的路径是什么?是
src/main/kipeoBundle吗?否则,你的结构是错误的。 -
[Doctrine\Common\Persistence\Mapping\MappingException] 找不到名为 'User.orm.xml' 的类 'main\kipeoBundle\Entity\User' 的映射文件。
-
您是否为其他实体使用
yml格式? -
是的,我使用 yml 格式
标签: php symfony frameworks doctrine fosuserbundle