2013-02-27 6 views
0

hi Я создаю собственный класс сущностей без использования командной строки.Ошибка создания пользовательской сущности в symfony2

так, что я создал один имя таблицы «профиль»

со следующими полями.

id:  type = integer,Pk, 
name:  type = string 
lastname: type = string, 
email: type = string 
gender: type = enum('male','female'), 
country: type = string 
state:  type = string, 
city:  type='string', 

что теперь у меня есть сделать создан один класс сущностей с именем «profile.php»

<?php 

    namespace Blogger\BlogBundle\Entity; 

    use Doctrine\ORM\Mapping as ORM; 

class Profile 
{ 

protected $id; 


protected $name; 

protected $lastname; 

protected $email; 

protected $image; 

protected $gender; 

protected $city; 

protected $state; 

protected $country; 


public function getName() 
{ 
    return $this->name; 
} 

public function setName($name) 
{ 
    $this->name = $name; 
} 

public function getLastName() 
{ 
    return $this->lastname; 
} 
public function setLastName($lastname) 
{ 
    $this->lastname = $lastname; 
} 

public function getEmail() 
{ 
    return $this->email; 
} 
public function setEmail($email) 
{ 
    $this->email = $email; 
} 

public function getImage() 
{ 
    return $this->image; 
} 
public function setImage($image) 
{ 
    $this->image = $image; 
} 

public function getGender() 
{ 
    return $this->gender; 
} 
public function setGender($gender) 
{ 
    $this->gender = $gender; 
} 

public function getCountry() 
{ 
    return $this->country; 
} 
public function setCountry($country) 
{ 
    $this->country = $country; 
} 

public function getState() 
{ 
    return $this->state; 
} 
public function setState($state) 
{ 
    $this->state = $state; 
} 

public function getCity() 
{ 
    return $this->city; 
} 
public function setCity($city) 
{ 
    $this->city = $city; 
} 
//public function 
} 
?> 

после того, что я создал один файл отображения доктрины «Profile.orm.yml».

Blogger\BlogBundle\Entity\Profile: 
type: profile 
table: null 
repositoryClass: Blogger\BlogBundle\Entity\ProfileRepository 
fields: 
    id: 
     type: integer 
     id: true 
     generator: 
      strategy: AUTO 
    name: 
     type: string 
     length: '255' 
    lastname: 
     type: string 
     length: '255' 
    email: 
     type: string 
     length: '255' 
    gender: 
     type: string 
     columnDefinition: enum('male','female') 
    image: 
     type: string 
     length: '255' 
    country: 
     type: string 
     length: '255' 
    state: 
     type: string 
     length: '255' 
    city: 
     type: string 
     length: '255' 

lifecycleCallbacks: { } 

В настоящее время проблема заключается в том, что когда я звоню на страницу профиля, приведена ниже ошибка?

Class "Blogger\BlogBundle\Entity\Profile" is not a valid entity or mapped super class. 

поэтому pls дайте мне знать, есть ли другое место, которое я должен забыть для кода. или часть ошибки в текущем файле. coz, когда я создаю объект, используя командную строку, тот же самый файл создается и работает нормально.

, но я хочу, чтобы пользователь создал файл, чтобы помочь мне. спасибо,

ответ

1

Прежде всего это YML так вопросы отступов (и улучшить читаемость);) Во-вторых один он должен быть типа «лица» не «профиль»

Blogger\BlogBundle\Entity\Profile: 
    type: entity 
    repositoryClass: Blogger\BlogBundle\Entity\ProfileRepository 
    fields: 
     id: 
      type: integer 
      id: true 
      generator: 
       strategy: AUTO 
     name: 
      type: string 
      length: '255' 
     lastname: 
      type: string 
      length: '255' 
     email: 
      type: string 
      length: '255' 
     gender: 
      type: string 
      columnDefinition: enum('male','female') 
     image: 
      type: string 
      length: '255' 
     country: 
      type: string 
      length: '255' 
     state: 
      type: string 
      length: '255' 
     city: 
      type: string 
      length: '255' 
    lifecycleCallbacks: { } 

Пожалуйста, используйте php app/console doctrine:schema:validate задачу, чтобы проверить, если у вас есть действительный схемы и картографической информации.