【发布时间】:2013-11-25 21:03:42
【问题描述】:
我在持久化实体时收到此错误
另一个“在链配置的命名空间中找不到类'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
}
?>
问题的任何提示?
非常感谢
【问题讨论】:
-
你想和我们分享'X'的名字吗?换句话说,错误到底发生在哪里?另外,仔细查看类/命名空间中的大写字母,确保它们与类的目录和文件名相同。
-
确定:在链配置的命名空间中找不到类 'NRtworks\SubscriptionBundle\Entity\Customer'
-
如果这可以帮助:在 /home/eagle1/www/Symfony2/vendor/doctrine/common/ 中的 MappingException ::classNotFoundInNamespaces ('NRtworks\SubscriptionBundle\Entity\Customer', array()) lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php 在第 114 行
标签: symfony doctrine-orm flush persist