mdantas/phinx-wrapper

This package simply phinx configuration by passing env vars to commands or base you app console to inject config by constructor.

1.0.0 2019-04-20 00:59 UTC

README

No have another library to manage migrations easily and simple like phinx, and i make this package to easily phinx commands or application console, is intention are you can add commands to your application console or use bin/phinxwrap by environments vars or inject Phinx\Config\Config to constructor of each command.

install

composer require mdantas/phinx-wrapper
//For generate env file, this not overwrite you env file.
vendor/bin/phinxwrap init_env
requirements

phinx 0.10.6

Environment example

DATABASE_MIGRATIONS_PATH=%%PHINX_CONFIG_DIR%%/db/migrations
DATABASE_SEEDS_PATH=%%PHINX_CONFIG_DIR%%/db/seeds
DATABASE_VERSION=creation
DATABASE_STAGE=development
DATABASE_ADAPTER=mysql
DATABASE_NAME=development_db
DATABASE_USER=root
DATABASE_PASSWORD=
DATABASE_HOST=localhost
DATABASE_PORT=3306
DATABASE_CHARSET=utf8

Examples

//In your app.php
//Config read from env or inject any place you need.
$config = \mdantas\PhinxWrap\PhinxConfiguration::envToConfigInterface(__DIR__.'/../')

$application = new \mdantas\PhinxWrap\ConsoleApplication(
        $config
);
public function __construct(\Phinx\Config\ConfigInterface $config)
{
    $this->addCommands([
        new Create($config),
        new Status($config),
        new Migrate($config),
        new Rollback($config),
        new SeedCreate($config),
        new SeedRun($config),
        new Test($config),
    ]);
}

Note

All phinx commands are based on package Symfony Console.