Symfony2.1 프로젝트에서 Doctrine2를 사용하여 (엔티티를 통해) 테이블에서 데이터를 가져 오는 데 문제가 있습니다. 여기에 내가 오류를 얻을 컨트롤러는 다음과 같습니다Symfony2.1 매핑 오류 : class_parents()
/**
* 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'));
}
엔티티 :
<?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
그리고이 오류입니다 :
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
Doctrine이 말한 것처럼 그것은 이상합니다. 콘솔은, 매핑이 제대로 수행됩니다 정보 : 매핑 : 나는 PHP 응용 프로그램을 실행/콘솔 교리를 테스트
[OK] Company\Project\BaseBundle\Entity\SYS_TCountry
을 내가 콘솔에서 쿼리를 실행하면 모든 것이 잘 간다 -> 응용 프로그램/콘솔 교리를 : 쿼리 : sql 'SELECT * FROM SYS_TCountry'는 결과를 반환합니다.
모르겠다. Symfony2.1 2.0 버전과 다른 설정이 필요하지만 매핑이 Doctrine 책임이므로 동일하게 보입니다.
'config.yml'의'orm' 섹션에 대한 설정은 무엇입니까? 귀하의 질문에 그것을 첨부 할 수 있습니까? –
예, 메시지에 첨부했으나 기본 설정입니다. 동일한 설정을 가진 다른 Symfony2 프로젝트에서 모든 것이 완벽하게 작동합니다 – unairoldan
아마도 수동으로 구성에서 매핑을 설정해야합니까? http://symfony.com/doc/current/reference/configuration/doctrine.html –