Reputation: 207
I have just installed FosUserBundle in a Symfony version 2.3.3 application. I'm able to manage users, login, register and whatnot but changes I make to my User class in MyApp\UserBundle\Entity aren't being applied when I run app/console doctrine:schema:update
The database structure contains: id, username, username_canonical, email, email_canonical, enabled, salt, password, last_login, locked, expired, expires_at, confirmation_token, password_requested_at, roles, credentials_expired, credentials_expire_at
The field that I have added, rate, isnt being created in the database structure no matter what I do.
Inside /app/AppKernel.php
new MyApp\UserBundle\MyAppUserBundle(),
new FOS\UserBundle\FOSUserBundle(),
Inside /app/config/config.yml
fos_user:
db_driver: orm
firewall_name: main
user_class: MyApp\UserBundle\Entity\User
registration:
confirmation:
enabled: true
And inside /src/MyApp/UserBundle/Entity/User.php
<?php
namespace MyApp\UserBundle\Entity;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* User
*
* @ORM\Table(name="fos_user")
* @ORM\Entity(repositoryClass="MyApp\UserBundle\Entity\UserRepository")
*/
class User extends BaseUser
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string
*
* @ORM\Column(name="token", type="string", length=255)
*/
private $token;
/**
* @var integer
*
* @ORM\Column(name="rate", type="integer")
*/
private $rate;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set token
*
* @param string $token
* @return User
*/
public function setToken($token)
{
$this->token = $token;
return $this;
}
/**
* Get token
*
* @return string
*/
public function getToken()
{
return $this->token;
}
/**
* Set rate
*
* @param integer $rate
* @return User
*/
public function setRate($rate)
{
$this->rate = $rate;
return $this;
}
/**
* Get rate
*
* @return integer
*/
public function getRate()
{
return $this->rate;
}
}
Upvotes: 0
Views: 1405
Reputation: 48865
Need to add MyUserBundle mappings to your config.yml file:
doctrine:
orm:
mappings:
FOSUserBundle: ~
MyUserBundle: ~
Upvotes: 0
Reputation: 2631
Don't forget the constructor, clear the cache and try php app/console doctrine:schema:update --force
namespace Acme\UserBundle\Entity;
use FOS\UserBundle\Model\User as BaseUser; use Doctrine\ORM\Mapping as ORM;
/** * @ORM\Entity * @ORM\Table(name="fos_user") / class User extends BaseUser { /* * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id;
public function __construct() { parent::__construct(); // your own logic }
}
Upvotes: 0