Jak*_*vák 2 php symfony doctrine-orm
我目前正在努力解决我的网络项目的问题。
我已经通过“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;
}
}
Run Code Online (Sandbox Code Playgroud)
多谢!
小智 6
错误来自不存在的迁移文件夹。
尝试将其添加到 config/packages/doctrine_migrations.yaml 中:
doctrine_migrations:
migrations_paths:
DoctrineMigrations: 'src/Migrations'
Run Code Online (Sandbox Code Playgroud)
如果 src/Migrations 文件夹不存在,则创建它。
| 归档时间: |
|
| 查看次数: |
3888 次 |
| 最近记录: |