1

I´m new on symfony. I´m getting this error when I try to run

$ php bin/console doctrine:generate:entities LoginBundle:Users

The autoloader expected class "LoginBundle\Entity\Users" to be defined in file ... The file was found but the class was not in it, the class name or namespace probably has a typo.

My entity is:

<?
// src/LoginBundle/Entity/Users.php
namespace LoginBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="users")
 */
class Users
{
    /**
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @ORM\Column(name="mail", type="string", length=100)
     */
    private $mail;

    /**
     * @ORM\Column(name="name", type="string", length=30)
     */
    private $name;

    /**
     * @ORM\Column(name="lastname", type="string", length=30)
     */
    private $lastname;

    /**
     * @ORM\Column(name="password", type="string", length=100)
     */
    private $password;

    public function getMail()
    {
        return $this->mail;
    }

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

    public function getLastname()
    {
        return $this->lastname;
    }

    public function getPassword()
    {
        return $this->password;
    }

    public function setMail($data)
    {
        $this->mail = $data;
        return;
    }

    public function setName($data)
    {
        $this->name = $data;
        return;
    }

    public function setLastname($data)
    {
        $this->lastname = $data;
        return;
    }

    public function setPassword($data)
    {
        $this->password = $data;
        return;
    }
}
6
  • Have you already tried to delete symfony cache? Commented Jun 28, 2017 at 15:39
  • 1
    change php open tag to <?php please not only <? Commented Jun 28, 2017 at 15:40
  • Hi @AlessandroMinoccheri how can I delete cache? and why I need to add the php to <? ? about that I change it and now I get another error: [Doctrine\DBAL\Exception\DriverException] An exception occured in driver: could not find driver Commented Jun 28, 2017 at 15:43
  • To clear the cache easily remove the directory var/cache/dev or prod depends on your environment. This is a new error of connection. I make an answer because this problem is solved with <?php open tag ok? Commented Jun 28, 2017 at 15:45
  • 1
    I have clarified It inside my answer Commented Jun 28, 2017 at 15:51

1 Answer 1

1

The php open tag is wrong, because it's a server configuration about short_open_tag

See the Documentation:

try to change

<?

to

<?php
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.