当我持久保存我的实体时,我收到此错误
另一个“在链配置的命名空间中找不到类'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');
}
当然,我的类实体存在,因为我可以基于它创建表单,对象等。 但是,这个实体不是“映射”意味着教义:mapping:info不会给我任何东西(但是我手动创建了相应的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
}
?>
问题的任何提示?
非常感谢
答案 0 :(得分: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是否有捆绑包,并仔细检查数据库连接是否正确。