2013-11-25 35 views
3

我得到這個錯誤時,我堅持我的實體另一個「之類的‘X’鏈配置的命名空間沒有被發現

另一個」之類的‘X’未在鏈中配置的命名空間

在將我的Symfony從Windows移到Linux之前,這已經用於工作了。

我的控制器:

public function SubscriptionHandlingAction(Request $request) 
{ 

     if ($request->isMethod('POST')) 
     { 

      $form = $this->createForm(new NewCustomer(), new Customer()); 
      $form->bind($request); 

      if ($form->isValid()) 
      { 

       // get the form data 
       $newcustomer = $form->getData();      

       //get the date and set it in the entity 
       $datecreation = new \DateTime(date('d-m-Y'));      
       $newcustomer->setdatecreation($datecreation); 

       //this works fine 
       echo $newcustomer->getname(); 

       //persist the data 
       $em = $this->getDoctrine()->getManager(); 
       $em->persist($newcustomer); 
       $em->flush(); 


       return $this->render('NRtworksSubscriptionBundle:Subscription:subscription_success.html.twig'); 

      } 

當然,我的課實體存在,因爲我可以在此基礎上創建的形式,對象等 然而,這個實體是不是「映射」的含義學說:映射:信息不給我任何東西(但我手動創建相應的SDL表,並把所有的註釋):

<?php 

namespace NRtworks\SubscriptionBundle\Entity; 

use Doctrine\ORM\Mapping as ORM; 
use Symfony\Component\Validator\Constraints as Assert; 


/** 
* @ORM\Entity 
* @ORM\Table(name="Customer") 
*/ 
class Customer 
{ 

    /** 
* @ORM\Id 
* @ORM\Column(type="integer") 
* @ORM\GeneratedValue(strategy="AUTO") 
*/ 

protected $idCustomer; 

/** 
* @ORM\Column(type="string", length=100, unique = true) 
*/ 

protected $name; 

/** 
* @ORM\Column(type="string", length=50) 
*/ 

protected $country; 

/** 
* @ORM\Column(type="datetime", nullable = false) 
*/ 

protected $datecreation; 

    /** 
* @ORM\Column(type="integer", length = 5, nullable = false) 
*/ 

protected $admin_user; 

//getter 
// no need for that 
// setter 
// no need for that 

} 

?> 

問題的任何暗示(S)?

非常感謝

+0

你想和我們分享'X'這個名字嗎?換句話說,錯誤究竟在哪裏發生?另外,請仔細看看類/名稱空間中的大寫字母,並確保它們與該類的目錄和文件名相同。 –

+0

肯定:如果這可以幫助,在鏈配置的命名空間 – Eagle1

+0

中找不到類'NRtworks \ SubscriptionBundle \ Entity \ Customer':在MappingException :: classNotFoundInNamespaces('NRtworks \ SubscriptionBundle \ Entity \ Customer',array()) 在114行/home/eagle1/www/Symfony2/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php – Eagle1

回答

5

您是否在使用多個實體管理器或連接?確保每個em都與config.yml中相應的包相匹配

doctrine: 
    dbal: 
    #connection info (driver/host/port/...) 
    orm: 
    entity_managers: 
     manager_one: 
     connection: # your connection (eg: 'default:' 
     mappings: 
      YourRespectiveBundle: ~ 
      AnotherrespectiveBundle: ~ 

這讓我第一次使用多個ems。 否則檢查你的包的AppKernel.php,並仔細檢查數據庫連接是否正確。

相關問題