PHPackages                             gridonic/migration-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. gridonic/migration-service-provider

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

gridonic/migration-service-provider
===================================

Doctrine migration service provider for Silex. Based on knplabs/migration-service-provider

v1.0.8(11y ago)042611MITPHPPHP &gt;=5.3.2

Since Aug 28Pushed 11y ago8 watchersCompare

[ Source](https://github.com/gridonic/MigrationServiceProvider)[ Packagist](https://packagist.org/packages/gridonic/migration-service-provider)[ Docs](http://gridonic.ch)[ RSS](/packages/gridonic-migration-service-provider/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (4)Versions (5)Used By (1)

MigrationServiceProvider
========================

[](#migrationserviceprovider)

[![Build Status](https://camo.githubusercontent.com/665f5af8632f2835d7637e2fcbb65e49b0f5e2f401a8217ac8276a5d315877d3/68747470733a2f2f7472617669732d63692e6f72672f677269646f6e69632f4d6967726174696f6e5365727669636550726f76696465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/gridonic/MigrationServiceProvider)

This is a simple homebrew schema migration system for silex and doctrine.

Install
-------

[](#install)

As usual, just include `gridonic/migration-service-provider` in your `composer.json` and register the service.

```
$app->register(new \Gridonic\Provider\MigrationServiceProvider(), array(
    'migration.path' => __DIR__.'/../src/Resources/migrations',
    'migration.register_before_handler' => true,
    'migration.migrations_table_name'   => 'migration_version',
));
```

KeyTypeOptionalDescription`migrations.path`String, folder path-Where are your migrations?`migrations.register_before_handler`BooleanxShould the service run the migrations on each boot?`migrations.migrations_table_name`StringxThe name of the table in the database, where the migration\_version is safed. Default `schema_version`Enough small talk, I want to write migrations!
----------------------------------------------

[](#enough-small-talk-i-want-to-write-migrations)

Perhaps, this documentation is not complete. So here are some links with more informations:

- [The official documentation for Doctrine's DBAL Schema Manager](http://readthedocs.org/docs/doctrine-dbal/en/latest/reference/schema-manager.html)
- [Original `KnpLabs\migration-service-provider`](https://github.com/KnpLabs/MigrationServiceProvider)

Running migrations
------------------

[](#running-migrations)

There are two ways of running migrations

### Using the `before` handler

[](#using-the-before-handler)

If you pass a `migration.register_before_handler` (set to `true`) when registering the service, then a `before` handler will be registered for migration to be run. It means that the migration manager will be run for each hit to your application.

You might want to enable this behavior for development mode, but please don't do that in production!

### Using the `migration:migrate` command

[](#using-the-migrationmigrate-command)

If you installed the console service provider right, you can use the `migration:migrate` command, so your app does not have to run the migrations each time when your web-Application is called.

Writing migrations
------------------

[](#writing-migrations)

A migration consist of a single file, holding a migration class. By design, the migration file must be named something like `_Migration.php` and located in `src/Resources/migrations`, and the class `Migration`. For example, if your migration adds a `bar` field to the `foo` table, and is the 5th migration of your schema, you should name your file `05_FooBarMigration.php`, and the class would be named `FooBarMigration`.

In addition to these naming conventions, your migration class must extends `Gridonic\Migration\AbstractMigration`, which provides a few helping method such as `getVersion` and default implementations for migration methods.

The migration methods consist of 4 methods, which are called in this order:

- `schemaUp`
- `appUp`
- `schemaDown`
- `appDown`

### schemaUp

[](#schemaup)

You get a `Doctrine\DBAL\Schema\Schema` instance where you can add, remove or modify the schema of your database.

### appUp

[](#appup)

After the `schemaUp`, you can edit the application - you get a `Silex\Application` instance for that. Here you can modify existing data after you have added a column.

### schemaDown

[](#schemadown)

After the `appUp`, you can modify the schema of your database again. You get a `Doctrine\DBAL\Schema\Schema` instance which you can use.

### appDown

[](#appdown)

Last but not least, you can work again with a `Silex\Application` instance. Modify the existing data or something like this.

Migration infos
---------------

[](#migration-infos)

There's one last method you should know about: `getMigrationInfos`. This method should return a self-explanatory description of the migration (it is optional though, and you can skip its implementation). If you use [Twig](http://twig.sensiolabs.org/), we have built in a `migration_infos` for twig - perhaps a function just for the developer-mode.

You can then use it with something like that:

```
      Migration informations: {{ migration_infos }}
```

Licence
-------

[](#licence)

The MigrationServiceProvider is licensed under the MIT license. The original library from is taken from the [KnpLabs](https://github.com/KnpLabs/MigrationServiceProvider).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 60% of commits — single point of failure

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 ~60 days

Total

3

Last Release

4152d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bb2697eab6fa08107a06c659fa99d2a68596547c8a1b280fe7c51f0dc30b1e64?d=identicon)[btemperli](/maintainers/btemperli)

---

Top Contributors

[![ubermuda](https://avatars.githubusercontent.com/u/10758?v=4)](https://github.com/ubermuda "ubermuda (9 commits)")[![dschenk](https://avatars.githubusercontent.com/u/706527?v=4)](https://github.com/dschenk "dschenk (1 commits)")[![maerlyn](https://avatars.githubusercontent.com/u/21580?v=4)](https://github.com/maerlyn "maerlyn (1 commits)")[![docteurklein](https://avatars.githubusercontent.com/u/109846?v=4)](https://github.com/docteurklein "docteurklein (1 commits)")[![Nek-](https://avatars.githubusercontent.com/u/972456?v=4)](https://github.com/Nek- "Nek- (1 commits)")[![rmasters](https://avatars.githubusercontent.com/u/34284?v=4)](https://github.com/rmasters "rmasters (1 commits)")[![marchenko1985](https://avatars.githubusercontent.com/u/88868?v=4)](https://github.com/marchenko1985 "marchenko1985 (1 commits)")

---

Tags

migrationdoctrineservicesilex

### Embed Badge

![Health badge](/badges/gridonic-migration-service-provider/health.svg)

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

###  Alternatives

[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58523.9M35](/packages/scienta-doctrine-json-functions)[martin-georgiev/postgresql-for-doctrine

Extends Doctrine with native PostgreSQL support for arrays, JSONB, ranges, PostGIS geometries, text search, ltree, uuid, and 100+ PostgreSQL-specific functions.

4485.3M4](/packages/martin-georgiev-postgresql-for-doctrine)[ssch/typo3-rector

Instant fixes for your TYPO3 PHP code by using Rector.

2592.8M262](/packages/ssch-typo3-rector)[dbtlr/silex-doctrine-migrations

Doctrine migration service provider for Silex

1123.8k1](/packages/dbtlr-silex-doctrine-migrations)

PHPackages © 2026

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