2012-01-02 72 views
0

即時通訊不知道這裏做了什麼錯誤。Symfony2 FOS用戶不是一個有效的實體

我按照說明如何安裝fos包並遇到問題。

我收到以下錯誤:

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

我的用戶類是在/src/RS/Entity/User.php

,我有'RS' => __DIR__.'/../vendor/reportsuite/src'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 
    } 
} 

據因爲我可以告訴這是一個映射en除非我錯過了什麼?

香港專業教育學院還試圖創建通過捆綁實體和另一束像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的東西,所以我就可以繼續工作。

+0

你可以從你的'config.yml'粘貼'doctrine:'條目嗎?我懷疑你沒有正確配置你的映射。 (見http://stackoverflow.com/questions/8636144/integrating-bundles-related-doctrine-2-entities-in-symfony-2-and-coupling/8637640#8637640) – 2012-01-02 15:07:30

+0

是否有一個原因,你爲什麼不使用默認的捆綁結構? – 2012-01-03 11:33:17

+0

該項目是動態的,客戶可以將自定義模塊拖入或拖出系統。所以我把代碼放在所有模塊全局的RS /中。除非這是錯誤的方法?我習慣於使用Zend Framework。 – 2012-01-03 15:48:51

回答

0

你檢查了一個命名空間嗎?

我覺得應該是:

namespace Namespace\YourBundle\Entity 

您可以用自己的捆綁使用的entites。

-1

有這個問題 - 不要忘了註解* @ORM\Entity象下面這樣:

/** 
* Powma\ServiceBundle\Entity\User 
* 
* @ORM\Entity 
* @ORM\Table(name="users") 
*/ 
0

運行

touch Entity/* 

,你都OK。

相關問題