gpt4 book ai didi

php - 学说使 :migration throws an error on class name generator

转载 作者:行者123 更新时间:2023-12-01 23:54:13 30 4
gpt4 key购买 nike

我目前正在努力解决我的网络项目中的问题。

我已经通过“bin/console make:entity”命令创建了一个“Voucher”实体,我想进行迁移以写入数据库。但是 Doctrine 抛出了一个奇怪的错误,我不知道如何修复它。谁能帮帮我?

Symfony 4.4.10 和 Doctrine 1.4

错误:

In ClassNameGenerator.php line 14:Argument 1 passed toDoctrine\Migrations\Generator\ClassNameGenerator::generateClassName()must be of the type string, null given, called in/var/www/skodanezajit/vendor/doctrine/migrations/lib/Doctrine/Migrations/Tools/Console/Command/DiffCommand.php on line 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 文件夹不存在,则创建它。

关于php - 学说使 :migration throws an error on class name generator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63037274/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com