Symfony 3.4 没有元数据类来处理错误 [英] Symfony 3.4 No Metadata Classes to process Error
问题描述
我已经安装了 symfony 3.4 和学说包
I have installed symfony 3.4 and doctrine packages
"php": ">=5.5.9",
"doctrine/doctrine-bundle": "^1.8",
"doctrine/doctrine-migrations-bundle": "^1.3",
"doctrine/orm": "^2.5",
"incenteev/composer-parameter-handler": "^2.0",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^5.0.0",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.6.4",
"symfony/symfony": "3.4.*",
"twig/twig": "^1.0||^2.0"
使用以下命令创建数据库
Created database using following command
php bin/console doctrine:database:create
G:\XAMPP\htdocs\project>php bin/console doctrine:schema:validate
[Mapping] OK - The mapping files are correct.
[Database] OK - The database schema is in sync with the mapping files.
G:\XAMPP\htdocs\project>php bin/console doctrine:schema:validate
[Mapping] OK - The mapping files are correct.
[Database] OK - The database schema is in sync with the mapping files.
G:\XAMPP\htdocs\project>php bin/console doctrine:schema:update --force
No Metadata Classes to process.
G:\XAMPP\htdocs\project>
每当我运行 php bin/console algorithm:schema:update --force 命令时,它都会抛出类似
Whenever i ran php bin/console doctrine:schema:update --force command it will throw an error like
没有要处理的元数据类.
No Metadata Classes to process.
我在文档中创建了实体类http://symfony.com/doc/3.4/doctrine.html
I created entity class as in the documentation http://symfony.com/doc/3.4/doctrine.html
产品实体类
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="product")
*/
class Product
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", length=100)
*/
private $name;
/**
* @ORM\Column(type="decimal", scale=2)
*/
private $price;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*
* @return Product
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set price
*
* @param integer $price
*
* @return Product
*/
public function setPrice($price)
{
$this->price = $price;
return $this;
}
/**
* Get price
*
* @return int
*/
public function getPrice()
{
return $this->price;
}
}
推荐答案
是的,我终于发现问题出在 John.orm.php
文件上,该文件会在我运行 php bin/时生成控制台教义:生成:实体
Yes finally i found the issue is with John.orm.php
file which will generated when i ran php bin/console doctrine:generate:entity
我使用以下命令创建了实体类
I have created Entity class using following command
php bin/console doctrine:generate:entity
然后它会提示
Welcome to the Doctrine2 entity generator
This command helps you generate Doctrine2 entities.
First, you need to give the entity name you want to generate.
You must use the shortcut notation like AcmeBlogBundle:Post.
The Entity shortcut name: AppBundle:John
Determine the format to use for the mapping information.
Configuration format (yml, xml, php, or annotation) [annotation]: php
Instead of starting with a blank entity, you can add some fields now.
Note that the primary key will be added automatically (named id).
Available types: array, simple_array, json_array, object,
boolean, integer, smallint, bigint, string, text, datetime, datetimetz,
date, time, decimal, float, binary, blob, guid.
New field name (press <return> to stop adding fields): id
Field "id" is already defined.
New field name (press <return> to stop adding fields): username
Field type [string]: string
Field length [255]:
Is nullable [false]: true
Unique [false]: false
New field name (press <return> to stop adding fields): password
Field type [string]:
Field length [255]:
Is nullable [false]: true
Unique [false]:
New field name (press <return> to stop adding fields): dob
Field type [string]: date
Is nullable [false]: true
Unique [false]:
New field name (press <return> to stop adding fields):
Entity generation
created .\src\AppBundle/Entity/John.php
created .\src\AppBundle/Resources/config/doctrine/
created .\src\AppBundle/Resources/config/doctrine/John.orm.php
> Generating entity class G:\XAMPP\htdocs\project\src\AppBundle\Entity\John.php:
OK!
> Generating repository class G:\XAMPP\htdocs\project\src\AppBundle\Repository\J
ohnRepository.php: OK!
> Generating mapping file G:\XAMPP\htdocs\project\src\AppBundle\Resources\config
\doctrine\John.orm.php: OK!
Everything is OK! Now get to work :).
G:\XAMPP\htdocs\project>
成功后会在AppBundle\Entity;
文件夹下创建实体类,在AppBundle\Repository;
文件夹下创建repository类,还会生成John.orm
AppBundle\Resources\config\doctrine\John.orm.php
And after success it will will create entity class in AppBundle\Entity;
folder and repository class in AppBundle\Repository;
also it will generate John.orm.php
in AppBundle\Resources\config\doctrine\John.orm.php
删除 John.orm.php 文件后,如果我运行 php bin/console algorithm:schema:update --force
然后它会生成表格.
After deleting John.orm.php file if i run php bin/console doctrine:schema:update --force
then it will generate tables.
这篇关于Symfony 3.4 没有元数据类来处理错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!