When inheriting the User-Class from FOSUserBundle, doctrine will not recognize the inherited properties of the base User class.
Only properties of my own class will be used in creating/updating the database schema.
This is the config.yml:
config.yml:
doctrine:
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
FOSUserBundle: ~
AppBundle: ~
fos_user:
db_driver: orm
firewall_name: main
user_class: AppBundle\Entity\User
My User-Entity:
<?php
namespace AppBundle\Entity;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity()
* @ORM\Table(name="s_user")
*/
class User extends BaseUser
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/** @ORM\Column(name="facebook_id", type="string", length=255, nullable=true) */
protected $facebook_id;
/** @ORM\Column(name="facebook_access_token", type="string", length=255, nullable=true) */
protected $facebook_access_token;
/** @ORM\Column(name="google_id", type="string", length=255, nullable=true) */
protected $google_id;
/** @ORM\Column(name="google_access_token", type="string", length=255, nullable=true) */
protected $google_access_token;
public function __construct()
{
parent::__construct();
// your own logic
}
What did i wrong here?
Try changing this line:
use FOS\UserBundle\Model\User as BaseUser;
To:
use FOS\UserBundle\Entity\User as BaseUser;
The missing fields should be added to the table structure on the next schema:update --force
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With