Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine make:migration throws an error on class name generator

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!

like image 846
Jakub Novák Avatar asked Jan 29 '26 09:01

Jakub Novák


1 Answers

Error come from an inexisting Migrations Folder.

Try to add this in you config/packages/doctrine_migrations.yaml:

doctrine_migrations:
    migrations_paths:
        DoctrineMigrations: 'src/Migrations'

And create src/Migrations folder if it does not exist.

like image 71
Robin Avatar answered Jan 31 '26 22:01

Robin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!