I am using Symfony 2.8, FOSUserBundle 1.3 and FOSOAuthServerBundle 1.5
For all of the class needed to those Bundles to work, I ended up with doctrine not updating my schema properly. I mean it doesn't take into account the fields from the Base Class.
CREATE TABLE oauh2_access_tokens (id INT NOT NULL, client_id INT NOT NULL, user_
id INT DEFAULT NULL, PRIMARY KEY(id));
CREATE TABLE oauth2_auth_codes (id INT NOT NULL, client_id INT NOT NULL, user_id
INT DEFAULT NULL, PRIMARY KEY(id));
CREATE TABLE oauth2_clients (id INT NOT NULL, PRIMARY KEY(id));
CREATE TABLE oauth2_refresh_tokens (id INT NOT NULL, client_id INT NOT NULL, use
r_id INT DEFAULT NULL, PRIMARY KEY(id));
Here's my config:
doctrine:
orm:
#auto_generate_proxy_classes: "%kernel.debug%"
default_entity_manager: default
entity_managers:
default:
connection: default
naming_strategy: doctrine.orm.naming_strategy.underscore
mappings:
COMPANYAuthBundle: ~
fos_user:
db_driver: orm
firewall_name: api
user_class: COMPANY\AuthBundle\Entity\User
#FOSOAuthBundle Configuration
fos_oauth_server:
db_driver: orm
client_class: COMPANY\AuthBundle\Entity\Client
access_token_class: COMPANY\AuthBundle\Entity\AccessToken
refresh_token_class: COMPANY\AuthBundle\Entity\RefreshToken
auth_code_class: COMPANY\AuthBundle\Entity\AuthCode
service:
user_provider: fos_user.user_manager
And here's my class User
<?php
namespace COMPANY\AuthBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Entity\User as BaseUser;
/**
* Utilisateur
*
* @ORM\Table(name="users")
* @ORM\Entity
*/
class User extends BaseUser
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
public function __construct()
{
parent::__construct();
// your own logic
}
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
}
So, yes I did put the right use and not FOS\UserBundle\Model\User as BaseUser;
Same thing for the class of OAuthServerBundle: (I'm just putting one here, they're all following the same pattern)
<?php
namespace COMPANY\AuthBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use FOS\OAuthServerBundle\Entity\Client as BaseClient;
/**
* Client
*
* @ORM\Table(name="oauth2_clients")
* @ORM\Entity(repositoryClass="COMPANY\AuthBundle\Repository\ClientRepository")
*/
class Client extends BaseClient
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
public function __construct()
{
parent::__construct();
}
}
Does anybody have an idea why base class' fields aren't put into my db? Thanks :)