0

hi I am creating a custom entity class without using command prompt.

so that I have created one table name " profile "

with the following fields.

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',

now what I have do is created one entity class named "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   
}
?>

after that I have created one doctrine mapping file "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: {  }

now the problem is when I am calling the profile page the bellow error is showed?

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

so pls let me know is there any other place I have to forget to code. or the error part in current file. coz, when I m generate the entity using the command prompt the same 2 file is created and that working fine.

but I want to customlly created the file so pls help me out. thanks,

Lain
  • 2,166
  • 4
  • 23
  • 47
Viraj.S
  • 305
  • 1
  • 8
  • 18

2 Answers2

1
type: entity
table: profile

should do the trick i think.

user1452962
  • 386
  • 3
  • 8
1

First of all it is YML so indentation matters (and improve readability) ;) Second one it should be type "entity" not "profile"

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: {  }

Please use php app/console doctrine:schema:validate task to check if you have valid schema and mapping information.

l3l0
  • 3,363
  • 20
  • 19