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 个解决方案
#1
10
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
php应用程序/控制台缓存:明确——env =刺激
#2
5
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. - 确保您的AdminBundle在AppKernel中注册。
- Make sure that entity manager's automapping is
true
. Or set it up correctly if you're using custom EM. - 确保实体管理器的自动操作是正确的。如果你使用的是自定义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.
我看到你在做一个菜单系统,我强烈建议你去看看Doctrine扩展树,它应该允许你比你的结构更有效地查询和编辑项目。
#3
5
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.
当我从命令行通过交互式生成器生成一个实体时,我遇到了同样的问题。当我第一次创建时,我将配置格式设置为PHP,但这并没有起作用。所以我删除了它并再次尝试,但是这次我选择了format = annotation。那么它工作!也许这能解决一个人的问题。
#4
4
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.
我在更新数据库时遇到了同样的问题。所以我遵循这个解决方案,我试着去适应我的情况,它起作用了。我认为这是一个自动化的问题,而且auto_mapping是正确的,symfony无法找到实体。我希望它能有所帮助。
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
#5
1
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:
您应该在app/config/config中设置这个配置。yml文件:
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.
尽管这是大多数情况下的最后一步,但您仍然可以使用-verbose来发现任何可能的问题。
bin/console doctrine:schema:update --verbose
#6
0
Make sure your entities are placed in your bundle's Entity
directory. In my case they were in Entities
instead.
确保您的实体被放置在bundle的实体目录中。在我的案例中,他们是在实体中。
#7
0
For me generating all the entities from the cmd did the work.
对我来说,从cmd生成所有的实体做了这项工作。
#8
0
In my case, i solve the problem creating the Entity folder. For some reason it had been eliminated. I hope that it can help.
在我的例子中,我解决了创建实体文件夹的问题。由于某种原因,它被淘汰了。我希望它能有所帮助。
#9
0
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!
我也遇到过同样的问题。对我来说,我的“实体”目录不在“AppBundle”中,而是在“src”目录中。将“实体”目录移动到“AppBundle”目录中,为我解决了问题!
#1
10
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
php应用程序/控制台缓存:明确——env =刺激
#2
5
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. - 确保您的AdminBundle在AppKernel中注册。
- Make sure that entity manager's automapping is
true
. Or set it up correctly if you're using custom EM. - 确保实体管理器的自动操作是正确的。如果你使用的是自定义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.
我看到你在做一个菜单系统,我强烈建议你去看看Doctrine扩展树,它应该允许你比你的结构更有效地查询和编辑项目。
#3
5
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.
当我从命令行通过交互式生成器生成一个实体时,我遇到了同样的问题。当我第一次创建时,我将配置格式设置为PHP,但这并没有起作用。所以我删除了它并再次尝试,但是这次我选择了format = annotation。那么它工作!也许这能解决一个人的问题。
#4
4
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.
我在更新数据库时遇到了同样的问题。所以我遵循这个解决方案,我试着去适应我的情况,它起作用了。我认为这是一个自动化的问题,而且auto_mapping是正确的,symfony无法找到实体。我希望它能有所帮助。
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
#5
1
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:
您应该在app/config/config中设置这个配置。yml文件:
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.
尽管这是大多数情况下的最后一步,但您仍然可以使用-verbose来发现任何可能的问题。
bin/console doctrine:schema:update --verbose
#6
0
Make sure your entities are placed in your bundle's Entity
directory. In my case they were in Entities
instead.
确保您的实体被放置在bundle的实体目录中。在我的案例中,他们是在实体中。
#7
0
For me generating all the entities from the cmd did the work.
对我来说,从cmd生成所有的实体做了这项工作。
#8
0
In my case, i solve the problem creating the Entity folder. For some reason it had been eliminated. I hope that it can help.
在我的例子中,我解决了创建实体文件夹的问题。由于某种原因,它被淘汰了。我希望它能有所帮助。
#9
0
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!
我也遇到过同样的问题。对我来说,我的“实体”目录不在“AppBundle”中,而是在“src”目录中。将“实体”目录移动到“AppBundle”目录中,为我解决了问题!