rmasters / doctrine-migrations-service-provider

Doctrine 迁移的 Pimple 服务提供程序

1.0.0 2014-07-26 23:28 UTC

This package is not auto-updated.

Last update: 2024-09-24 03:11:47 UTC


README

为 Pimple (Silex, Cilex) 应用程序提供 Doctrine DBAL 迁移。基于 Symfony 的 Doctrine Migrations Bundle

使用 Dragonfly Development 的 Pimple ORM 服务提供程序来查找您的数据库模式和您的实体之间的差异。

还使用 KnpLabs 的 Console 服务提供程序注册了一些控制台命令。

安装

  1. Composer 需要此包

    composer require "rmasters/doctrine-migrations-service-provider:~1.0"
    
  2. 在您的应用程序中注册

    $app = new Silex\Application;
    $app = new Pimple\Container;
    
    $app->register(new KnpLabs\Provider\ConsoleServiceProvider, [
        'console.name' => 'Application',
        'console.version' => '1',
        'console.project_directory' => __DIR__ . '/../', // your project root
    ]);
    
    $app->register(new Dflydev\Provider\DoctrineOrm\DoctrineOrmServiceProvider, [
        'orm.proxies.dir' => __DIR__ . '/Proxies',
        'orm.em.options' => [
            'mappings' => [
                [
                    'type' => 'annotation',
                    'namespace' => 'Application\Entity',
                    'path' => __DIR__ . '/../src/Entity',
                    'resources_namespace' => 'Application\Entity',
                    'use_simple_annotation_reader' => false, // Set this to false if you import @ORM for annotations
                ],
            ],
        ],
    ]);
    
    $app->register(new Rossible\DoctrineMigrationsProvider\DoctrineMigrationsServiceProvider, [
        'doctrine.migrations.namespace' => 'Application\Migration',
        'doctrine.migrations.dir_name' => __DIR__ . '/../src/Migration',
    ]);

此包需要 Pimple 3.x,并使用它提供的 ServiceProviderInterface 和 Container 接口/类型提示。Silex 2.0 支持,Cilex 应该很快也会支持。

配置

命令

这些命令与 Symfony 的 Doctrine Migrations bundle 中的命令相同。

您需要设置一个可以执行控制台命令的 PHP 脚本。有关示例,请参阅 src/Resources/console.php

许可证

MIT 许可证 下发布。