我已经安装了symfony3.4和条令包
"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"
使用以下命令创建数据库
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/consoledoctrine:schema:update--force命令它将抛出如下错误
没有要处理的元数据类。
我在文档中创建了实体类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;
}
}
2条答案
按热度按时间avkwfej41#
是的,我终于发现问题出在
John.orm.php
运行时生成的文件php bin/console doctrine:generate:entity
我使用以下命令创建了实体类然后它会提示
成功后,它将在中创建实体类
AppBundle\Entity;
中的文件夹和存储库类AppBundle\Repository;
它也会产生John.orm.php
在AppBundle\Resources\config\doctrine\John.orm.php
如果我运行php bin/console doctrine:schema:update --force
然后它将生成表。pu3pd22g2#
大多数情况下,此错误是由于实体路径问题和缓存造成的。实体php文件必须在您的特定文件夹中。通常我们通过命令生成实体:
先运行命令
然后再试试