hamichen/laminas-doctrine-orm 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hamichen/laminas-doctrine-orm

最新稳定版本:1.0.1

Composer 安装命令:

composer require hamichen/laminas-doctrine-orm

包简介

Simple Laminas/Mezzio Doctrine ORM integration

README 文档

README

Simple Laminas/Mezzio Doctrine ORM integration.

Please feel free to report bugs and missing features.

Using

Configuration

Create config file config/autoload/doctrine.global.php with minimal config:

  • doctrine - Key for doctrine config
    • connection
      • orm_default
        • driver_class - Full name of \Doctrine\DBAL\Driver implementation
        • params - Driver parameters
    • driver - Mapping driver configuration
      • orm_default
        • drivers
          • Key must be a namespace for entities (e.g. App\Entity)
            • class - Full name of MappingDriver
            • paths - Array of directories with entities

See Doctrine documentation for more possible configurations.

Example

<?php
declare(strict_types=1);

use Doctrine\DBAL\Driver\PDO\MySQL\Driver;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;

return [
    'doctrine' => [
        'connection' => [
            'orm_default' => [
                'driver_class' => Driver::class,
                'params' => [
                    'host'     => 'localhost',
                    'port'     => '3306',
                    'user'     => 'root',
                    'password' => 'root',
                    'dbname'   => 'database',
                ],
            ],
        ],
        
        'driver' => [
            'orm_default' => [
                'drivers' => [
                    'App\Entity' => [
                        'class' => AnnotationDriver::class,
                        'paths' => [
                            'src/Entity',
                        ],
                    ],
                ],
            ],
        ],
    ],
];

Migrations Commands

Commands uses Laminas CLI and vendor/bin/laminas entry point for it

Possible commands

doctrine:migrations:diff         [diff] Generate a migration by comparing your current database to your mapping information.
doctrine:migrations:dump-schema  [dump-schema] Dump the schema for your database to a migration.
doctrine:migrations:execute      [execute] Execute a single migration version up or down manually.
doctrine:migrations:generate     [generate] Generate a blank migration class.
doctrine:migrations:latest       [latest] Outputs the latest version number
doctrine:migrations:migrate      [migrate] Execute a migration to a specified version or the latest available version.
doctrine:migrations:rollup       [rollup] Rollup migrations by deleting all tracked versions and insert the one version that exists.
doctrine:migrations:status       [status] View the status of a set of migrations.
doctrine:migrations:up-to-date   [up-to-date] Tells you if your schema is up-to-date.
doctrine:migrations:version      [version] Manually add and delete migration versions from the version table.

Example

$ vendor/bin/laminas doctrine:migrations:diff
$ vendor/bin/laminas doctrine:migrations:migrate

TODO

  1. Tests
  2. Split this library into separate DBAL, ORM and Migrations libraries
  3. Add libraries support (auth, pagination etc)

WHY

Because DoctrineORMModule is only for Laminas (full MVC) but I need simple integration for Mezzio.

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2022-08-23