Symfony2 FOS 用户不是有效实体
我不确定我在这里做错了什么。
我按照有关如何安装 fos 捆绑包的说明进行操作,但遇到了问题。
我收到以下错误:
PHP 致命错误:未捕获的异常 'Doctrine\ORM\Mapping\MappingException' 带有消息 'Class RS\Entity\User 不是有效的实体或映射的超类。在 路径\vendor\doctrine\lib\Doctrine\ORM\Mapping\MappingException.php:142
我的用户类位于 /src/RS/Entity/User.php
并且我有'RS' => __DIR__.'/../vendor/reportsuite/src'
in app/autoload.php
该类是
<?php
// /src/RS/Entity/User.php
namespace RS\Entity;
use FOS\UserBundle\Entity\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
}
}
据我所知这是一个映射实体,除非我错过了一些东西?
我还尝试过通过捆绑包和另一个捆绑包(如 Acme/UserBundle/Entity/User.php )创建实体,
# Doctrine Configuration
doctrine:
dbal:
default_connection: default
connections:
default:
dbname: axpdb
user: %database_user%
password: %database_password%
host: %database_host%
port: %database_port%
charset: UTF8
reportsuite:
dbname: reportsuite
user: %database_user%
password: %database_password%
host: %database_host%
port: %database_port%
charset: UTF8
orm:
entity_managers:
default:
connection: default
mappings:
ReportSuiteMainMenuBundle: ~
reportsuite:
connection: reportsuite
mappings:
# Security
jms_security_extra:
secure_controllers: true
secure_all_services: false
# FOS User Config
#fos_user:
# db_driver: orm
# firewall_name: main
# user_class: RS\Entity\User
# model_manager_name: reportsuite
我有 2 个需要访问的数据库,并且我已经注释掉了 fos 内容,以便我可以继续在职的。
im not sure what ive done wrong here.
I am following the instruction on how to install the fos bundle and have come across a problem.
I am getting the following error:
PHP Fatal error: Uncaught exception
'Doctrine\ORM\Mapping\MappingException' with message 'Class
RS\Entity\User is not a valid entity or mapped super class.' in
PATH\vendor\doctrine\lib\Doctrine\ORM\Mapping\MappingException.php:142
My user class is in /src/RS/Entity/User.php
And i have'RS' => __DIR__.'/../vendor/reportsuite/src'
in app/autoload.php
The class is
<?php
// /src/RS/Entity/User.php
namespace RS\Entity;
use FOS\UserBundle\Entity\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
}
}
As far as i can tell this is a mapped entity, unless im missing something?
Ive also tried creating the entity in by bundle and another bundle like Acme/UserBundle/Entity/User.php
# Doctrine Configuration
doctrine:
dbal:
default_connection: default
connections:
default:
dbname: axpdb
user: %database_user%
password: %database_password%
host: %database_host%
port: %database_port%
charset: UTF8
reportsuite:
dbname: reportsuite
user: %database_user%
password: %database_password%
host: %database_host%
port: %database_port%
charset: UTF8
orm:
entity_managers:
default:
connection: default
mappings:
ReportSuiteMainMenuBundle: ~
reportsuite:
connection: reportsuite
mappings:
# Security
jms_security_extra:
secure_controllers: true
secure_all_services: false
# FOS User Config
#fos_user:
# db_driver: orm
# firewall_name: main
# user_class: RS\Entity\User
# model_manager_name: reportsuite
I have 2 databases that I need to access and I have commented out the fos stuff so i can continue working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您检查了命名空间吗?
我认为应该是:
您可以使用所有捆绑包中的实体。
Did You checkd a namespace ?
I think it should be:
You can use entites from all of Your bundles.
运行
一下就OK了。
Run
and you are OK.
遇到这个问题 - 不要忘记注释
* @ORM\Entity
如下所示:Had this problem - don't forget the annotation
* @ORM\Entity
like below: