Symfony2 No Metadata Classes to process
Solution 1
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
Solution 2
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.
Solution 3
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
Solution 4
So entity manager didn't create metadata for your entity. Here are things I would check first:
- Clear your cache
- Make sure your
AdminBundle
is registered in AppKernel. - 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.
Solution 5
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
Comments
-
Ivan almost 2 years
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; // ... }
-
mediaroot about 8 yearsYou saved my day. Thank you. This worked for me like charm
-
mickburkejnr over 7 yearsHad this issue with Symfony 3.1, and this answer solved the problem.
-
Liz over 7 yearsFixed it for me :)
-
Thomas L. about 5 yearsFixed it for me