Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

migrations:status

Boa tarde! Ao Executar o comando " migrations:status "

Apresenta a seguinte mensagem:

In MigrationsNamespaceRequired.php line 13:

Migrations namespace must be configured in order to use Doctrine migrations.

Migrations.php


return [
    'name' => 'Fundamentos Doctrine',
    'migrations_namespace' => 'Alura\\Doctrine\\Migrations',
    'table_name' => 'doctrine_migration_versions',
    'column_name' => 'version',
    'column_length' => 14,
    'executed_at_column_name' => 'executed_at',
    'migrations_directory' => 'src/Migrations',
    'all_or_nothing' => true,
];

Aluno.php


namespace Alura\Doctrine\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;

/**
 * @Entity
 * @Table(name="Aluno")
 */
class Aluno
{
    /**
     * @Id
     * @GeneratedValue
     * @Column(type="integer")
     */
    private int $id;
    /**
     * @Column(type="string") 
     */
    private string $name;
    /**
     * @OneToMany(targetEntity="Telefone", mappedBy="Aluno")
     */
    private Collection $telefones;

    public function __construct()
    {
        $this->telefones = new ArrayCollection();
    }
    public function getId(): int
    {
        return $this->id;
    }

    public function getName(): string
    {
        return $this->name;
    }

    public function setName(string $name): self
    {
        $this->name = $name;
        return $this;
    }

    public function addTelefone(Telefone $telefone): self
    {
        $this->telefone->add($telefone);
        $telefone->setAluno($this);
        return $this;
    }

    public function getTelefones(): Collection
    {
        return $this->telefones;
        //return new Collection();
    }
}

Telefone.php


namespace Alura\Doctrine\Entity;

/**
 * @Entity
 * @Table(name="Telefone")
 */
class Telefone
{
    /**
     * @Id
     * @GeneratedValue
     * @Column(type="integer")
     */
    private int $id;
    // Definir tamanho (Type="string" length=15)
    /**@Column(type="string") */
    private string $number;
    /**
     * @ManyToOne(targetEntity="Aluno")
     */
    private Aluno $aluno;

    public function getId(): int
    {
        return $this->id;
    }

    public function getNumber(): string
    {
        return $this->number;
    }

    public function setNumber(string $number): self
    {
        $this->$number = $number;
        return $this;
    }

    public function getAluno(): Aluno
    {
        return $this->alunno;
    }
    public function setAluno(Aluno $aluno): self
    {
        $this->aluno = $aluno;
        return $this;
    }
}
1 resposta
solução!

O problema estava no nome do arquivo migrations.php, estava faltando um "s".

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software