- Single PHAR file for your projects
DiffCommand
for migrations (if an Entity Manager is available)- Support for custom
ArgvInput
in CLI instance - Support for custom
ConsoleOutput
in CLI instance
You can dowload latest version of doctrine-migrations.phar.
If you'll build your own doctrine-migrations.phar
see instruction below.
You can install deps using [Composer] (http://getcomposer.org/):
$ php composer.phar install
$ php package.php
It creates ./build/doctrine-migrations.phar
If you receive an error that looks like:
creating archive "build/doctrine-migrations.phar" disabled by INI setting
This can be fixed by setting the following in your php.ini:
; http://php.net/phar.readonly
phar.readonly = Off
Define how migrations will be stored and tracked within your database:
name: Doctrine Sandbox Migrations
migrations_namespace: DoctrineMigrations
table_name: doctrine_migration_versions
migrations_directory: /path/to/migrations/classes/DoctrineMigrations
By default Doctrine does not map the MySQL enum type to a Doctrine type. This is because Enums contain state (their allowed values) and Doctrine types don’t. You can register MySQL ENUMs to map to Doctrine strings. This way Doctrine always resolves ENUMs to Doctrine strings.
name: Doctrine Sandbox Migrations
migrations_namespace: DoctrineMigrations
table_name: doctrine_migration_versions
migrations_directory: /path/to/migrations/classes/DoctrineMigrations
mapping_types:
enum: string
Define how to connect to your database:
return array(
'driver' => 'pdo_mysql',
'host' => 'localhost',
'user' => 'migrations',
'password' => 'm1gr@t10n$',
'dbname' => 'doctrine_sandbox'
);
Specify defaults or provide your own custom ArgvInput
, should you so desire:
$input = new \Symfony\Component\Console\Input\ArgvInput;
... make some changes ...
return $input;
If your database migrations contain HTML, you may run into issues with outputting the SQL to the console.
This is because the ConsoleOutput
class uses HTML-like tags for styling certain messages, such as error
s,
info
messages, etc.
For HTML to render properly, you can customize the ConsoleOutput
within this file as follows:
$output = new \Symfony\Component\Console\Output\ConsoleOutput;
$output->setStyle('p'); // Adds default styling to the 'p' tag, as to not throw a rendering exception
return $output;
All available documentation can be found here.