您好我正在创建一个自定义实体类而不使用命令提示符。
这样我就创建了一个表名“profile”
具有以下字段。
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.
所以请让我知道还有其他地方我必须忘记编码。或当前文件中的错误部分。因为,当我使用命令提示符生成实体时,会创建相同的 2 文件并且工作正常。
但我想自定义创建文件,所以请帮助我。谢谢,