2016-10-24 4 views
2

내 문제에 대해 stackoverflow를 검색했지만 내 문제에 대한 대답을 찾지 못했습니다.Symfony 프로덕션 매핑 예외 FOSUserBundle

현재 PHP 5.6.26 following the documentation on the symfony website을 실행하는 데비안 서버에 symfony 프로젝트를 배포하고 있습니다.

[Doctrine\ORM\Mapping\MappingException] Class "AppBundle\Entity\User" sub class of "FOS\UserBundle\Model\User" is not a valid entity or mapped super class.

내 개발 컴퓨터의 (윈도우 10이 오류를 가지고 있지 않다 : 나는 composer install --no-dev --optimize-autoloader

나는 다음과 같은 오류를 얻을 명령을 실행하여 내 번들을 설치하는 명령을 실행

데스크탑 및 Macbook)

현재 무엇이 잘못 될 수 있는지에 대한 실마리가 없습니다. 나중에 프로젝트에서 annotation에서 yml로 전환했습니다.

User.php 파일 :

<?php 

namespace AppBundle\Entity; 

use FOS\UserBundle\Model\User as BaseUser; 

/** 
* User 
*/ 
class User extends BaseUser 
{ 

    public function __construct() 
    { 
     parent::__construct(); 
    } 

    protected $id; 

    /** 
    * @var \AppBundle\Entity\Address 
    */ 
    private $address; 


    /** 
    * Set address 
    * 
    * @param \AppBundle\Entity\Address $address 
    * 
    * @return User 
    */ 
    public function setAddress(\AppBundle\Entity\Address $address = null) 
    { 
     $this->address = $address; 

     return $this; 
    } 

    /** 
    * Get address 
    * 
    * @return \AppBundle\Entity\Address 
    */ 
    public function getAddress() 
    { 
     return $this->address; 
    } 
} 

내 User.orm.yml 파일 : 나는 100 % 확실하지 않다,하지만 난 user가 예약 된 SQL 키워드입니다 see a note here

AppBundle\Entity\User: 
    type: entity 
    table: user 
    repositoryClass: AppBundle\Repository\UserRepository 
    id: 
     id: 
      type: integer 
      id: true 
      generator: 
       strategy: AUTO 
    lifecycleCallbacks: { } 

    oneToOne: 
     address: 
     targetEntity: AppBundle\Entity\Address 
     cascade: ["persist", "remove"] 

답변

1

Alvin Bunk의 답변을 본 후 자원 (src/AppBundle의) 폴더가 그의 답변에서 대문자로 표시된다는 것을 알았습니다. 확인한 후, Resources 폴더가 대문자로 표시되지 않았습니다.

내 수정 : src/AppBundle/

2

, 파일을 다음과 같이 변경해야 할 수도 있습니다.

AppBundle\Entity\User: 
    type: entity 
    table: fos_user 

그게 효과가 있는지 보시 겠어요? 나는 확신하지 못합니다. 그러나 그것을 시도하십시오.

+0

폴더를 자원를 대문자 I가 fos_user에 테이블 이름을 변경했습니다. 하지만 작동하지 않았다. – Debreker

+0

FOSUserBundle을 포함하도록 app/AppKernel.php 파일을 편집했다고 가정합니다. (http://symfony.com/doc/current/bundles/FOSUserBundle/index.html#step -2 - 사용 - 번들). 그렇지 않으면, 나는 다른 것을 생각할 수 없다. 그것은 꽤 솔직해야합니다. –

+0

** 리소스 ** 폴더가 귀하의 답변에 대문자로 표기된 것을 보았습니다. 내 폴더 자원 (src/AppBundle에 있음)이 변경된 후에 프로젝트가 시작되어 실행되지 않았습니다! 감사! – Debreker

관련 문제