Unable to create user table

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

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

But the console returns the following message

Do not update anything - your database is already synchronized with the current metadata of the object

I am using Symfony 2.1 and the latest version for 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 my site, I have this error:

MappingException: class "Krpano \ UserBundle \ Entity \ User" was not found in the name chains specified by the chain FOS \ UserBundle \ Entity, Krpano \ ServicesBundle \ Entity

Can you help me?

+4
source share
5 answers

Do not update anything - your database is already synchronized with the current metadata of the object

It is assumed that your organization is not registered due to a missing ad in AppKernel.php.

Doctrine is only a search in the active package.

After adding the line:

 new Krpano\UserBundle\KrpanoUserBundle(), 

Like:

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

Try the following:

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

If Doctrine returns:

 Database schema updated successfully! "1" queries were executed 

Your problem is resolving.

My answer is simply the completion of Carlos Granados's answer.

+4
source

Add

 new Krpano\UserBundle\KrpanoUserBundle(), 

To your application file / AppKernel.php

+3
source

I had this error and it was caused by accidentally deleting the @ORM\Entity() from my entity class. D'o.

+1
source

I had the same problem as you. You skipped creating yml for Doctrine Entity. This file is required for Doctrine to generate shema in your database.

 # src/Acme/UserBundle/Resources/config/doctrine/User.orm.yml Acme\UserBundle\Entity\User: type: entity table: fos_user id: id: type: integer generator: strategy: AUTO 

Then, in the console, update autoload for the composer

 composer dump-autoload 

Then call the Doctrine Schema Designer

 php app/console doctrine:schema:update --force 
+1
source

Using composer.phar dump-autoload --optimize

Also causes this error on startup:

php app/console cache:clear --env=prod --no-debug

If you run:

./composer.phar update

again, everything works again.

0
source

All Articles