Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine doesn't map fields from FOSUserBundle User-class

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?

like image 526
delete Avatar asked Jun 17 '26 22:06

delete


1 Answers

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

like image 195
chalasr Avatar answered Jun 19 '26 12:06

chalasr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!