rnr1721 / le7-db-doctrine
le7 PHP MVC 框架的 Doctrine ORM 集成
0.1.4
2024-01-28 19:57 UTC
Requires
- php: >=8.1
- doctrine/dbal: ^3.7
- doctrine/doctrine-bundle: ^2.11
- doctrine/doctrine-migrations-bundle: ^3.3
- doctrine/orm: ^2.17
- rnr1721/le7-core: ^1.1
Requires (Dev)
- phpunit/phpunit: ^10.0
- vimeo/psalm: ^5.7
Replaces
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>