php - Doctrine make:migration 在类名生成器上抛出错误
问题描述
我目前正在努力解决我的网络项目中的问题。
我通过“bin/console make:entity”命令创建了一个“凭证”实体,我想进行迁移以写入数据库。但是 Doctrine 抛出了一个奇怪的错误,我不知道如何解决它。谁能帮我?
Symfony 4.4.10 和 Doctrine 1.4
错误:
在 ClassNameGenerator.php 第 14 行:传递给 Doctrine\Migrations\Generator\ClassNameGenerator::generateClassName() 的参数 1 必须是字符串类型,给定 null,在 /var/www/skodanezajit/vendor/doctrine/migrations/lib/ 中调用Doctrine/Migrations/Tool s/Console/Command/DiffCommand.php 在第 139 行
凭证实体:
<?php
namespace App\Entity;
use App\Repository\VoucherRepository;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=VoucherRepository::class)
*/
class Voucher
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $code;
/**
* @ORM\Column(type="datetime")
*/
private $dateCreated;
/**
* @ORM\Column(type="datetime")
*/
private $lastsTo;
/**
* @ORM\Column(type="integer")
*/
private $value;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $used;
public function getId(): ?int
{
return $this->id;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
public function getDateCreated(): ?\DateTimeInterface
{
return $this->dateCreated;
}
public function setDateCreated(\DateTimeInterface $dateCreated): self
{
$this->dateCreated = new \DateTime('now');
return $this;
}
public function getLastsTo(): ?\DateTimeInterface
{
return $this->lastsTo;
}
public function setLastsTo(\DateTimeInterface $lastsTo): self
{
$this->lastsTo = new \DateTime('now +6 months');
return $this;
}
public function getValue(): ?int
{
return $this->value;
}
public function setValue(int $value): self
{
$this->value = $value;
return $this;
}
public function getUsed(): ?bool
{
return $this->used;
}
public function setUsed(?bool $used): self
{
$this->used = $used;
return $this;
}
}
非常感谢!
解决方案
错误来自不存在的迁移文件夹。
尝试将其添加到您的 config/packages/doctrine_migrations.yaml 中:
doctrine_migrations:
migrations_paths:
DoctrineMigrations: 'src/Migrations'
如果不存在,则创建 src/Migrations 文件夹。
推荐阅读
- javascript - POST 请求中缺少授权标头
- python - 包含任何元素的列表的最大可能乘积
- php - 问题 SQLSTATE[HY000]: 一般错误:1215 无法添加外键约束
- html - 谷歌文本到语音 api html GET 请求中的多个参数
- database - 如果我想使用 Amazon DynamoDB 作为我的移动应用程序的数据库,我可以选择哪个 Ec2 实例?
- python - 理解尝试跳过循环的 N 次迭代时的错误
- r - 如何在 R 中使用多个数据框绘制分组条形图?
- java - 为什么我们不能通过java中的getter实现深度克隆为什么我们需要带有Cloneable接口的原型设计模式?
- powershell - 如何更改多个 .txt 文件中的字符并保存/覆盖 Powershell 中的现有文件
- linux - 删除警告:二进制文件拱门(1)不匹配包拱门(2)