-
-
Save jmny/c957de6984c9d939c059 to your computer and use it in GitHub Desktop.
// see also https://github.com/robmorgan/phinx/issues/364 | |
$phinxApp = new \Phinx\Console\PhinxApplication(); | |
$phinxTextWrapper = new \Phinx\Wrapper\TextWrapper($phinxApp); | |
$phinxTextWrapper->setOption('configuration', '/path/to/phinx.yml'); | |
$phinxTextWrapper->setOption('parser', 'YAML'); | |
$phinxTextWrapper->setOption('environment', 'development'); | |
$log = $phinxTextWrapper->getMigrate(); |
+1
+1
Thanks so much for this! It should be in the official docs!
Hi
When I run above commands it works but nothing happens in the database. Please see my output
C:/xampp/htdocsstring(266) "Phinx by CakePHP - https://phinx.org. 0.10.6 using config file .\vendor\bin\phinx.php using config parser php using migration paths using seed paths using environment development using adapter mysql using database production_db All Done. Took 0.0841s "
Also i am putting my code here
require DIR . '/vendor/autoload.php';
$phinxApp = new \Phinx\Console\PhinxApplication();
$phinxTextWrapper = new \Phinx\Wrapper\TextWrapper($phinxApp);
$phinxTextWrapper->setOption('configuration', 'C:/xampp/htdocs/CI_PROJECT/phinix/vendor/bin/phinx.php');
$phinxTextWrapper->setOption('parser', 'php');
$phinxTextWrapper->setOption('environment', 'development');
$log = $phinxTextWrapper->getMigrate('development','-t');
var_dump($log);
Oh my goodness, something that actually worked! THANK YOU!
Also, a trap for beginners, don't forget to autoload composer:
require __DIR__ . '/vendor/autoload.php';