I currently struggling with problem on my web project.
I have created a "Voucher" entity through "bin/console make:entity" command and i would like to make a migration to write to to the database. But Doctrine throws a weird error and I dont know how to fix it. Can anyone help me?
Symfony 4.4.10 & Doctrine 1.4
The error:
In ClassNameGenerator.php line 14: Argument 1 passed to Doctrine\Migrations\Generator\ClassNameGenerator::generateClassName() must be of the type string, null given, called in /var/www/skodanezajit/vendor/doctrine/migrations/lib/Doctrine/Migrations/Tool s/Console/Command/DiffCommand.php on line 139
Voucher entity:
<?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;
}
}
Thanks a lot!
php bin/console doctrine:migrations:diff
instead ofphp bin/console make:migration
? - Gillu13