PHPackages                             japerman/start-migration - 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. japerman/start-migration

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

japerman/start-migration
========================

Simple migrations system for php

00PHP

Since Aug 20Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Japerman/Start-migration)[ Packagist](https://packagist.org/packages/japerman/start-migration)[ RSS](/packages/japerman-start-migration/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Start-migration
===============

[](#start-migration)

Database migration tool for PHP

How does it work?
-----------------

[](#how-does-it-work)

```
$ start migrate
```

Start aims to be vendor/framework independent, and in doing so, requires you to do a little bit of work up front to use it.

Start requires a bootstrap file, that must return an object that implements the ArrayAccess interface with several predefined keys. We recommend returning an instance of [Pimple](https://github.com/fabpot/Pimple), a simple dependency injection container. This is also an ideal opportunity to expose your own services to the migrations themselves, which have access to the container, such as a [schema management abstraction](http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/schema-manager.html).

Getting Started
---------------

[](#getting-started)

The best way to install start is using composer:

```
$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar require japerman/start-migration
```

You can then use the localised version of start for that project

```
$ bin/start --version
```

Start can do a little configuring for you to get started, go to the root of your project and:

```
$ start init
+d ./migrations
+f ./start.php
$
```

+d ./migrations Place your migration files in here

+f ./start.php Create services in here

Note that you can move start.php to config/start.php, the commands will look first in the config directory than in the root.

Start can generate migrations using the generate command. Migration files are named versionnumber\_name.php, where version number is made up of 0-9 and name is CamelCase or snake\_case. Each migration file should contain a class with the same name as the file in CamelCase.

```
$ start generate AddRatingToLolCats
+f ./migrations/20201018171411_AddRatingToLolCats.php
$ start status

 Status   Migration ID    Migration Name
-----------------------------------------
   down  20201018171929  AddRatingToLolCats

Use the migrate command to run migrations

$ start migrate
 == 20201018171411 AddRatingToLolCats migrating
 == 20201018171411 AddRatingToLolCats migrated 0.0005s
$ start status

 Status   Migration ID    Migration Name
-----------------------------------------
     up  20201018171929  AddRatingToLolCats
$
```

Better Persistence
------------------

[](#better-persistence)

The init command creates a bootstrap file that specifies a flat file to use to track which migrations have been run, which isn't great. You can use the provided adapters to store this information in your database.

```
