2016-02-26 46 views
0

我正在使用Doctrine2構建Zend Framework 2網站。我是開發Windows和一切工作,但我已經上傳我的代碼到Linux環境,這個錯誤已經出現:原則:在Windows上映射,但在Linux上映射

The target-entity LeuerOneYear\Entity\UserLeagueRole cannot be found in 'User\Entity\User#leagueRoles'. 

這是我的實體:

<?php 

namespace User\Entity; 

use Doctrine\ORM\Mapping as ORM; 
use Gedmo\Mapping\Annotation as Gedmo; 
use LeuerOneYear\Entity\UserLeagueRole; 
use Doctrine\Common\Collections\ArrayCollection; 

/** 
* User 
* 
* @ORM\Table(name="user") 
* @ORM\Entity 
*/ 
class User 
{ 
    /** 
    * @var integer 
    * 
    * @ORM\Column(name="UserId", type="integer", nullable=false) 
    * @ORM\Id 
    * @ORM\GeneratedValue(strategy="IDENTITY") 
    */ 
    private $id; 

    /** 
    * @var string 
    * 
    * @ORM\Column(name="Login", type="string", length=15, nullable=false) 
    */ 
    private $login; 

    /** 
    * @var string 
    * 
    * @ORM\Column(name="password", type="string", length=45, nullable=false) 
    */ 
    private $password; 

    /** 
    * @var string 
    * 
    * @ORM\Column(name="Email", type="string", length=100, nullable=false) 
    */ 
    private $email; 

    /** 
    * @var \DateTime 
    * @Gedmo\Timestampable(on="create") 
    * @ORM\Column(name="CreatedOn", type="datetime", nullable=false) 
    */ 
    private $createdon; 

    /** 
    * 
    * @var string 
    */ 
    private $appRole; 

    /** 
    * 
    * @var \Doctrine\Common\Collections\Collection 
    * 
    * @ORM\OneToMany(targetEntity="LeuerOneYear\Entity\UserLeagueRole", mappedBy="user", cascade={"persist"}) 
    */ 
    private $leagueRoles; 

和:

<?php 

namespace LeuerOneYear\Entity; 

use Doctrine\ORM\Mapping as ORM; 
use User\Entity\User; 

/** 
* Userleaguerole 
* 
* @ORM\Table(name="userleaguerole", indexes={@ORM\Index(name="UserRole_League_idx", columns={"LeagueId"}), @ORM\Index(name="UserRole_Role_idx", columns={"RoleId"}), @ORM\Index(name="IDX_5D9987ED631A48FA", columns={"UserId"})}) 
* @ORM\Entity 
*/ 
class UserLeagueRole 
{ 
//  /** 
//  * @var \User\Entity\User 
//  * 
//  * @ORM\Id 
//  * @ORM\GeneratedValue(strategy="NONE") 
//  * @ORM\OneToMany(targetEntity="User\Entity\User", mappedBy="leaguerole") 
//  * }) 
//  */ 
    /** 
    * 
    * @var User\Entity\User $user 
    * 
    * @ORM\Id 
    * @ORM\GeneratedValue(strategy="NONE") 
    * @ORM\ManyToOne(targetEntity="User\Entity\User", inversedBy="leagueRoles") 
    * @ORM\JoinColumn(name="UserId", referencedColumnName="UserId") 
    */ 
    private $user; 

    /** 
    * @var \LeuerOneYear\Entity\League 
    * 
    * @ORM\Id 
    * @ORM\GeneratedValue(strategy="NONE") 
    * @ORM\ManyToOne(targetEntity="LeuerOneYear\Entity\League", inversedBy="userRoles") 
    * @ORM\JoinColumn(name="LeagueId", referencedColumnName="LeagueId") 
    * 
    */ 
    private $league; 

    /** 
    * @var \LeuerOneYear\Entity\LeagueRole 
    * 
    * @ORM\ManyToOne(targetEntity="LeuerOneYear\Entity\LeagueRole") 
    * @ORM\JoinColumns({ 
    * @ORM\JoinColumn(name="RoleId", referencedColumnName="RoleId") 
    * }) 
    */ 
    private $role; 

正如你可以看到用戶和UserLeagueRole之間的ManyToOne關係。

你知道爲什麼這個映射在Windows上工作,但在Linux中失敗嗎?

回答

0

我真的很傻的錯誤:

這是我的目錄結構:

RootFolder /模塊/ LeuerOneYear/src目錄/ leuerOneYear

然後在我的module.config.php配置我的學說司機這種方式:

'driver' => array(
         __NAMESPACE__ . '_driver' => array(
           'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver', 
           'cache' => 'array', 
           'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity') 
         ), 
         'orm_default' => array(
           'drivers' => array(
             __NAMESPACE__ . '\Entity' => __NAMESPACE__ . '_driver' 
           ) 
         ), 
       ), 

__NAMESPACE__是 'leuerOneYear',而不是 'leuerOneYear',從而爲Linux環境中ensitive,映射失敗。

我剛剛更名爲module/src/leuerOneyear to module/src/LeuerOneYear