Tag Archives: phinx

Access custom phinx variable inside seed/migration

Any variable passed in the environment config can be accessed from a seed/migration (after run()) through the adapter options $this->getAdapter()->getOptions().

For example, the phinx.php:

return [
    'environments' => [
        'default_migration_table' => 'phinxlog',
        'default_database' => 'production',
                'production' => [
                    'adapter' => 'mysql',
                        'name' => 'proddb',
                        'host' => 'localhost',
                        'user' => 'proddb',
                        'pass' => 'password',
                        'custom_thing' => $custom_thing,
                ],
    ],
];

Then in the migration/seed:

$this->getAdapter()->getOptions()['custom_thing'];