2016-10-24 4 views
2

私の問題についてはstackoverflowで検索しましたが、私の問題の答えは見つかりませんでした。Symfonyプロダクションマッピング例外FOSUserBundle

現在、PHP 5.6.26 following the documentation on the symfony websiteを実行している私のDebianサーバに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.

私は私の開発マシンの(Windowsの10でこのエラーを持っていないよ。私は composer install --no-dev --optimize-autoloader

は、私は次のようなエラーにgetコマンドを実行して、私のバンドルをインストールするためのコマンドを実行し

デスクトップとMacBook)

現在私は何が間違っているのか分からない。プロジェクトの後半でアノテーションから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ファイル:

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内)のフォルダが彼の答えで大文字になっているのを見ました。 チェックした後、私のリソースフォルダは大文字ではありませんでした。

私の修正:私はfos_userにテーブル名を変更しsrc/AppBundle/

2

、私は100%確実ではないんだけど、私はuserは予約SQLキーワードであることをsee a note here ファイルを次のように変更する必要があります。

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

それが動作するか試してみることができますか? 私は確かではありませんが、試してみてください。

+0

にフォルダにリソースを大文字にします。それはうまくいきませんでした – Debreker

+0

私は 'app/AppKernel.php'を編集してFOSUserBundle [ここに記載されている](http://symfony.com/doc/current/bundles/FOSUserBundle/index.html#step -2-enabled-the-bundle)である。そうでなければ、私は他の何かを考えることができません。それはかなりまっすぐ進むはずです。 –

+0

**リソース**フォルダがあなたの答えで大文字になっているのを見ました。私のフォルダリソース(src/AppBundle内)は、これを変更しても、私のプロジェクトは起動しています!ありがとう! – Debreker

関連する問題