Symfony2.1-Zuordnungsfehler: class_parents ()
Ich habe ein Problem beim Versuch, mithilfe von Doctrine2 in einem Symfony2.1-Projekt Daten aus einer Tabelle (über eine Entität) abzurufen. Hier ist der Controller, bei dem ich den Fehler erhalte:
/**
* Country list
*/
public function countrylistAction()
{
$em = $this->getDoctrine()->getManager();
$countryList = $em->getRepository('ProjectBaseBundle:SYS_TCountry')
->findAll();
$serializer = new Serializer(array(new GetSetMethodNormalizer()),
array('json' => new JsonEncoder()));
return new Response($serializer->serialize($countryList, 'json'));
}
Die Entität:
<?php
namespace Company\Project\BaseBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
* @ORM\Table(name="SYS_TCountry")
*/
class SYS_TCountry
{
/**
* @ORM\Id
* @ORM\Column(type="string", length=3, nullable=false)
* @var string
*/
protected $idcountry;
/**
* @ORM\Column(type="string", length=75, nullable=false)
* @Assert\NotBlank()
* @var string
*/
protected $name;
....
public function getIdcountry() { return $this->idcountry; }
public function getName() { return $this->name; }
public function getA2() { return $this->a2; }
public function getA3() { return $this->a3; }
public function getIdstatus() { return $this->idstatus; }
public function setIdcountry($idcountry) { $this->idcountry = $idcountry; }
public function setName($name) { $this->name = $name; }
public function setA2($a2) { $this->a2 = $a2; }
public function setA3($a3) { $this->a3 = $a3; }
public function setIdstatus($idstatus) { $this->idstatus = $idstatus; }
public function __toString() { return $this->idcountry; }
}
Config.yml:
# Doctrine Configuration
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
Und das ist der Fehler:
Warning: class_parents():
Class Company\Project\BaseBundle\Entity\SYS_TCountry does not exist and could not be loaded in
/var/www/project/src/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php line 40
Es ist seltsam, weil, wie Doctrine in der Konsole sagt, das Mapping korrekt durchgeführt wird: Ich teste, ob es ausgeführt wirdPHP App / Konsole Doktrin: Mapping: Info:
[OK] Company\Project\BaseBundle\Entity\SYS_TCountry
und wenn ich eine Abfrage in der Konsole ausführe, geht alles in Ordnung -> App / Konsole-Doktrin: query: sql 'SELECT * FROM SYS_TCountry', die Ergebnisse zurückgeben.
Ich weiß nicht, ob mitSymfony2.1 Ich muss etwas anderes als die 2.0-Version konfigurieren, aber es scheint dasselbe zu sein, da die Zuordnung in der Verantwortung von Doctrine liegt.