Ivan
Ivan

Reputation: 5248

Symfony2 No Metadata Classes to process

After creating entity with:

php app/console doctrine:generate:entity

and while using:

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

I encountered:

No Metadata Classes to process.

Entity

namespace ISLab\AdminBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="menu_items")
 */
class MenuItem
{
    /**
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @ORM\Column(name="parent", type="integer")
     */
    private $parent;

    // ...
}

Upvotes: 8

Views: 19018

Answers (9)

Milander
Milander

Reputation: 1061

I've had the same issue. For me it was that my directory called 'Entity' was not in the 'AppBundle' but in the 'src' directory. Moving the 'Entity' directory into the 'AppBundle' directory fixed the problem for me!

Upvotes: 0

Peyman Mohamadpour
Peyman Mohamadpour

Reputation: 17954

for anyone on the same thing, these are few steps to go:

1. Clear the cache:

bin/console c:c --env=dev
bin/console c:c --env=prod

If you see any errors meanwhile, try to cover it by inspecting source of problem.

2. Inspect your configuration:

According to this sample directory structure:

Application
|
└- src
   |
   └- Acme
      |
      └- Bundle
         |
         └- BlogBundle
            |
            └- Model
               |
               └- Entity

You should have this configuration inside your app/config/config.yml file:

doctrine:

    ...

    orm:
        auto_generate_proxy_classes: '%kernel.debug%'
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true
        mappings:
            AcmeBlogBundle:
                mapping: true
                type: annotation
                dir: Model/Entity
                alias: Blog
                prefix: Acme\Bundle\BlogBundle\Model\Entity
                is_bundle: true

3. Update your database schema:

You can now update your database schema without any problems:

bin/console doctrine:schema:update

despite of this being the final step for most cases, you may still use --verbose to find any further possible problems.

bin/console doctrine:schema:update --verbose

Upvotes: 1

Valentino Mantovani
Valentino Mantovani

Reputation: 1

In my case, i solve the problem creating the Entity folder. For some reason it had been eliminated. I hope that it can help.

Upvotes: 0

rdiyanova
rdiyanova

Reputation: 1

For me generating all the entities from the cmd did the work.

Upvotes: 0

gtsouk
gtsouk

Reputation: 5263

Make sure your entities are placed in your bundle's Entity directory. In my case they were in Entities instead.

Upvotes: 0

lv92
lv92

Reputation: 161

I had the same problem when i update the database. So i follow this solution and i tried to adapt in my case and it works. I think that is a problem of automapping indeed also with auto_mapping setted true, symfony wasn't able to find the entities. I hope that it can help.

  orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    naming_strategy: doctrine.orm.naming_strategy.underscore
    auto_mapping: true
    mappings:
        AppBundle:
            type: annotation
            is_bundle: false
            dir: %kernel.root_dir%/../src/AppBundle/Entity/
            prefix: AppBundle\Entity
            alias: AppBundle

Upvotes: 5

pdolinaj
pdolinaj

Reputation: 1145

I had the same problem when I generate an Entity through the interactive generator from command line. When I first created I set the Configuration Format to PHP and that didn't work. So I deleted it and tried again but this time I selected format = annotation. Then it worked! Maybe this could solve someone's problem.

Upvotes: 6

MarcSitges
MarcSitges

Reputation: 282

I had a similar problem and took me a while until I find out how to clear out the cache. Clearing only doctrine's cache did not work for me. Use the command below to clear the entire environment (production one in this case)

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

Upvotes: 11

Igor Pantović
Igor Pantović

Reputation: 9246

So entity manager didn't create metadata for your entity. Here are things I would check first:

  1. Clear your cache
  2. Make sure your AdminBundle is registered in AppKernel.
  3. Make sure that entity manager's automapping is true. Or set it up correctly if you're using custom EM.

A bit offtopic:

I see you're making a menu system and I would strongly suggest you to check out Doctrine Extensions Tree which should allow you to query and edit items much more efficiently than with your structure.

Upvotes: 5

Related Questions