Symfony2 No Metadata Classes to process

2019-02-05 01:10发布

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;

    // ...
}

9条回答
▲ chillily
2楼-- · 2019-02-05 01:29

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

查看更多
做自己的国王
3楼-- · 2019-02-05 01:31

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!

查看更多
你好瞎i
4楼-- · 2019-02-05 01:33

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
查看更多
登录 后发表回答