rnr1721/le7-db-doctrine

le7 PHP MVC 框架的 Doctrine ORM 集成

0.1.4 2024-01-28 19:57 UTC

README

本包将 Doctrine ORM 集成到 le7 PHP MVC 引擎中。

设置

您需要在 ./config/db_doctrine.php 文件中设置数据库连接

在控制器中使用

您可以将 EntityManagerInterface 注入到您的控制器中

<?php

namespace App\Controller\Web;

use Doctrine\ORM\EntityManagerInterface;
use Psr\Http\Message\ResponseInterface;

class IndexController
{

    public function indexAction(EntityManagerInterface): ResponseInterface
    {   

        // Use Entity Manager

    }

}

Doctrine 命令行工具

您可以使用 doctrine 命令行工具的以下方式

./cli.sh doctrine <doctrine options>