PHPackages                             codito/doctrine-migrations-service-provider - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. codito/doctrine-migrations-service-provider

AbandonedArchivedLibrary[Database &amp; ORM](/categories/database)

codito/doctrine-migrations-service-provider
===========================================

Doctrine Migrations service provider for Silex applications

v2.1.0(9y ago)31.3k1MITPHPPHP &gt;=5.4

Since Nov 3Pushed 8y ago1 watchersCompare

[ Source](https://github.com/CoditoNet/DoctrineMigrationsServiceProvider)[ Packagist](https://packagist.org/packages/codito/doctrine-migrations-service-provider)[ RSS](/packages/codito-doctrine-migrations-service-provider/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (10)Used By (0)

Doctrine Migrations Service Provider
====================================

[](#doctrine-migrations-service-provider)

Provides [Doctrine Migrations](https://github.com/doctrine/migrations) commands in [Silex](http://silex.sensiolabs.org/) applications by extending console with additional commands. Those commands are wrappers for base Doctrine Migrations commands and for proper working require console application to be instance of console provided by [Codito Console Service Provider](https://github.com/CoditoNet/silex-console-provider), because commands need access to some services and/or config options to properly resolve migrations configuration.

Requirements
------------

[](#requirements)

- PHP &gt;= 5.4 because of traits and short array syntax.

Installation
------------

[](#installation)

Add entries to `composer.json`:

```
"require": {
    "codito/doctrine-migrations-service-provider": "~2.0"
}
```

Configuration
-------------

[](#configuration)

In order to use Doctrine Migrations commands in your console, you have to configure few things:

- `DoctrineServiceProvider` (one of Silex's default providers)
- `ConsoleServiceProvider` from [here](https://github.com/CoditoNet/silex-console-provider)
- `DoctrineOrmServiceProvider` from [here](https://github.com/dflydev/dflydev-doctrine-orm-service-provider), optionally (required only for `migrations:diff` command)
- `DoctrineMigrationsServiceProvider` itself

`DoctrineMigrationsServiceProvider` supports configuration both for single and multiple connections/entity managers.

Example config
--------------

[](#example-config)

Register `DoctrineServiceProvider` (can be also configured with `db.options`, then it will be `default` connection)

```
$app->register(new DoctrineServiceProvider(), array(
    'dbs.options' => array(
        'some_connection' => array(
            'driver'   => 'pdo_mysql',
            'dbname'   => 'silex',
            'host'     => 'localhost',
            'user'     => 'root',
            'password' => null,
            'port'     => null,
        )
    )
));
```

Register `ConsoleServiceProvider`

```
$app->register(new \Codito\Silex\Provider\ConsoleServiceProvider(), array(
    'console.name'              => 'Silex App',
    'console.version'           => '1.0.0',
));
```

Register `DoctrineMigrationsServiceProvider`:

```
$app->register(new \Codito\Silex\DoctrineMigrationsService\Provider\DoctrineMigrationsServiceProvider(), array(
    'db.migrations.options' => array(
        'some_connection' => array(
            'dir_name' => realpath(__DIR__ . '/Application/Migrations'),
            'namespace' => 'Application\\Migrations',
            'table_name' => 'migration_versions',
            'name' => 'Application Migrations',
        )
    )
));
```

Configuration of `DoctrineMigrationsServiceProvider` is always under `db.migrations.options`, regardless to single or multiple configs. Those configs are related to `db.options`/`dbs.options` and names must match in order to work correctly.

Optionally, if you need `migrations:diff` command, you may want to register

```
$app->register(new Dflydev\Silex\Provider\DoctrineOrm\DoctrineOrmServiceProvider(), array(
    'orm.proxies_dir' => __DIR__ . '/../var/orm',
    'orm.ems.options' => array(
        'some_entity_manager' => array(
            'connection' => 'some_connection', // Important if you have custom connection name
            'mappings' => array(
                // Using actual filesystem paths
                array(
                    'type' => 'annotation',
                    'namespace' => 'Application\Entity',
                    'path' => __DIR__ . '/Application/Entity',
                    'use_simple_annotation_reader' => false // Support for "use Doctrine\ORM\Mapping AS ORM" -> "@ORM\Entity"
                ),
            ),
        )
    ),
));
```

If you want to use complex annotations, like `@ORM\Entity`, you have to set `use_simple_annotation_reader` to `false` like above. However it requires to configure `AnnotationRegistry` on your own, like:

```
$loader = require_once __DIR__.'/../vendor/autoload.php';
\Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
```

It should be done in `console` executable file.

Usage
-----

[](#usage)

Just run `php bin/console` (or wherever you have `console`) and commands list will appear. Each command has own help, to view it just type `php bin/console some:command:from:your:commands:list --help`.

If you did everything properly, complete migration commands would look like:

```
doctrine
  doctrine:migrations:diff       Generate a migration by comparing your current database to your mapping information.
  doctrine:migrations:execute    Execute a single migration version up or down manually.
  doctrine:migrations:generate   Generate a blank migration class.
  doctrine:migrations:latest     Outputs the latest version number
  doctrine:migrations:migrate    Execute a migration to a specified version or the latest available version.
  doctrine:migrations:status     View the status of a set of migrations.
  doctrine:migrations:version    Manually add and delete migration versions from the version table.

```

Container aware migrations
--------------------------

[](#container-aware-migrations)

Since `v2.1` there is possibility to use migrations with auto-injected Pimple container (Silex app). If you need cointainer inside migrations, just implement `Codito\Silex\DoctrineMigrationsService\Migration\ContainerAwareMigration`interface or extend `Codito\Silex\DoctrineMigrationsService\Migration\AbstractContainerAwareMigration`. This is helpful if you have multiple connections and migration for one connection requires data from other connection or if some service must be called in order to execute migration.

Please notice
-------------

[](#please-notice)

Depending on your config you have to (or don't) pass `--db`/`--em` param to command. `--db` is used for most of commands, `--em` is only for `doctrine:migrations:diff` and it will automatically set `--db` option based on `connection` attribute in entity manager's config.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity64

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~128 days

Recently: every ~77 days

Total

9

Last Release

3178d ago

Major Versions

v0.5 → v2.0.02017-03-27

PHP version history (2 changes)v0.1PHP &gt;=5.3.2

v0.2PHP &gt;=5.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/029d590a49d9d6abf71a378ae4e4a3ee74ab50366f9e91ab64efd8d789bbbfb6?d=identicon)[Codito](/maintainers/Codito)

---

Tags

schemadoctrinedbalmigrationssilex

### Embed Badge

![Health badge](/badges/codito-doctrine-migrations-service-provider/health.svg)

```
[![Health](https://phpackages.com/badges/codito-doctrine-migrations-service-provider/health.svg)](https://phpackages.com/packages/codito-doctrine-migrations-service-provider)
```

###  Alternatives

[doctrine/doctrine-migrations-bundle

Symfony DoctrineMigrationsBundle

4.3k177.9M537](/packages/doctrine-doctrine-migrations-bundle)[laravel-doctrine/migrations

Doctrine Migrations for Laravel

782.8M16](/packages/laravel-doctrine-migrations)[mnapoli/dbal-schema

DB schema manager for Doctrine DBAL

9732.9k1](/packages/mnapoli-dbal-schema)[nettrine/migrations

Doctrine Migrations for Nette Framework

411.7M17](/packages/nettrine-migrations)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
