Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Impossible to generate the table "user"

When I install FOSUserBundle (official documentation), I try to generate my table fos_user using this command:

php app/console doctrine:schema:update --force

But console returns the following message

Nothing to update - your database is already in sync with the current entity metadata

I use Symfony 2.1 and the last version to FOSUserBundle.

app/AppKernel.php contains

new FOS\UserBundle\FOSUserBundle(),

app/config/config.yml contains

fos_user:
    db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
    firewall_name: main
    user_class: Krpano\UserBundle\Entity\User

src/Krpano/UserBundle/Entity/User.php contains

namespace Krpano\UserBundle\Entity;

use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="pouet")
 */
class User extends BaseUser
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    public function __construct()
    {
        parent::__construct();
        // your own logic
    }
}

And when I try to access to my website I have this error:

MappingException: The class 'Krpano\UserBundle\Entity\User' was not found in the chain configured namespaces FOS\UserBundle\Entity, Krpano\ServicesBundle\Entity

Can you help me?

like image 616
guizme555 Avatar asked Jan 15 '23 17:01

guizme555


2 Answers

Nothing to update - your database is already in sync with the current entity metadata

Implies that your entity is not registred because of a missing declaration in AppKernel.php.

Doctrine only search on bundle who are active.

After added the line :

new Krpano\UserBundle\KrpanoUserBundle(),

Like that:

public function registerBundles()
    {
            $bundles = array(    
            ...
            new Krpano\UserBundle\KrpanoUserBundle(),
            new FOS\UserBundle\FOSUserBundle(),    
            ...

        ); ...

Try this:

php app/console doctrine:schema:update --force

If Doctrine return:

Database schema updated successfully! "1" queries were executed

Your problem is resolve.

My answer is just a completion to Carlos Granados answer.

like image 70
Mehdi Aïssani Avatar answered Jan 25 '23 16:01

Mehdi Aïssani


Add

new Krpano\UserBundle\KrpanoUserBundle(),

To your app/AppKernel.php file

like image 32
Carlos Granados Avatar answered Jan 25 '23 16:01

Carlos Granados