Doctrine 条令ORM和slim php-为新创建的表手动添加类

Doctrine 条令ORM和slim php-为新创建的表手动添加类,doctrine,slim,Doctrine,Slim,我正在开发一个遗留应用程序,这是我第一次使用doctrine(通常是rails的家伙) 我在db上手动创建了一个名为“零食”的新表(命名约定为all caps) 我创建了一个models/entities/Snack.dcm.yaml文件: Snack: type: entity table: SNACKS fields: id: id: true type: integer unsi

我正在开发一个遗留应用程序,这是我第一次使用doctrine(通常是rails的家伙)

我在db上手动创建了一个名为“零食”的新表(命名约定为all caps)

我创建了一个models/entities/Snack.dcm.yaml文件:

Snack:
    type: entity
    table: SNACKS
    fields:
        id:
            id: true
            type: integer
            unsigned: false
            nullable: false
            generator:
                strategy: IDENTITY
        patient_id:
            type: integer
            unsigned: false
            nullable: false
        snack_name:
            type: string
            length: 50
            fixed: false
            nullable: false
        created_at:
            type: datetime
            nullable: false
        updated_at:
            type: datetime
            nullable: false
    lifecycleCallbacks: {  }
但仍会出现此错误:
[Semantical error]第0行,第14列“snakp s”附近:错误:未定义类“snakp”。

我还注意到model dir“model/”中有一些文件,并复制了这些文件:

<?php



use Doctrine\ORM\Mapping as ORM;

/**
 * Snacks
 */
class Snack
{
    /**
     * @var integer
     */
    private $id;

    /**
     * @var integer
     */
    private $patient_id;

    /**
     * @var text
     */
    private $snack_name;

    /**
     * @var datetime
     */
    private $created_at;

    /**
     * @var datetime
     */
    private $updated_at;


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


    /**
     * Get id
     *
     * @return integer 
     */
    public function getPatientId()
    {
        return $this->patient_id;
    }


    public function setPatientId($patient_id)
    {
            $this->patient_id = $patient_id;
        return $this->patient_id;
    }

    /**
     * Set name
     *
     * @param string $name
     * @return Medicines
     */
    public function setSnackName($name)
    {
        $this->snack_name = $name;

        return $this;
    }

    /**
     * Get name
     *
     * @return string 
     */
    public function getSnackName()
    {
        return $this->snack_name;
    }

    /**
     * Set generic
     *
     * @param string $generic
     * @return Medicines
     */
    public function setCreatedAt($datetime)
    {
        $this->created_at = $datetime;

        return $this;
    }

    /**
     * Get generic
     *
     * @return string 
     */
    public function getCreatedAt()
    {
        return $this->created_at;
    }

    /**
     * Set contraInd
     *
     * @param string $contraInd
     * @return Medicines
     */
    public function setUpdatedAt($datetime)
    {
        $this->updated_at = $datetime;

        return $this;
    }
}

好吧,通过阅读一篇条令教程,最终找到了composer的bootstrap.php文件,找到了解决方法

看起来以前的开发人员手动需要所有的模型文件,所以我不得不在那里添加require

希望这能帮助别人