Доктрина не показывает мне атрибуты - PullRequest
0 голосов
/ 30 марта 2019

Код класса:

use Doctrine\ORM\Mapping as ORM;

/**
 * Items
 *
 * @ORM\Table(name="items")
 * @ORM\Entity
 */
class Items
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    protected $id;

    /**
     * @var string
     *
     * @ORM\Column(name="nombre", type="string", length=50, nullable=false)
     */
    protected $nombre;

    /**
     * Items constructor.
     */
    public function __construct()
    {
    }

    /**
     * @param int $id
     */
    public function setId($id)
    {
        $this->id = $id;
    }

    /**
     * @param string $nombre
     */
    public function setNombre($nombre)
    {
        $this->nombre = $nombre;
    }


    /**
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @return string
     */
    public function getNombre()
    {
        return $this->nombre;
    }
}

И метод, который он использовал со слимом

$app->get('/prova', function ($request, $response, $args) use ($serializer) {
    try {
        $db = connectDb();

        $profesorRepository = $db->getRepository('Items');
        $professors = $profesorRepository->findAll();
        return json_encode($professors);
    } catch (Exception $exc) {
        echo $exc->getTraceAsString();
        echo "\n";
        echo $exc->getMessage();
    }
});

В моем проекте у меня есть index.php в корне папки и сущностей в src/Entity папке

...