Phinx: php vendor/bin/phinx init does not work

Created on 9 May 2016  路  5Comments  路  Source: cakephp/phinx

Hello,
in your documentation you write "Phinx can now be executed from within your project:"

php vendor/bin/phinx init

But this command throws me this

dir=$(d=${0%[/\\]*}; cd "$d"; cd "../robmorgan/phinx/bin" && pwd)

# See if we are running in Cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
        # Cygwin paths start with /cygdrive/ which will break windows PHP,
        # so we need to translate the dir path to windows format. However
        # we could be using cygwin PHP which does not require this, so we
        # test if the path to PHP starts with /cygdrive/ rather than /usr/bin
        if [[ $(which php) == /cygdrive/* ]]; then
                dir=$(cygpath -m $dir);
        fi
fi

dir=$(echo $dir | sed 's/ /\ /g')
"${dir}/phinx" "$@"

As I found out phinx or phinx.bat are not php files. I can run phinx.bat via

cd vendor/bin
phinx.bat init

But this creates yaml config file to bin foleder NOT in the root as you write in documentation.
Have you any working docu?

Thank you.

Most helpful comment

Are you on windows? Try without php and use windows separators:
vendor\bin\phinx init

All 5 comments

Are you on windows? Try without php and use windows separators:
vendor\bin\phinx init

Yes you are right. Windows separator works. Thanks.

I also ran into this issue and noticed that phinx is installed differently in Windows vs. Linux. In Windows (with Windows shell as well as with Git Bash, which is probably Cygwin), composer installs a Shell script ("phinx") as well as a Batch file ("phinx.bat") into vendor/bin. In Linux, I get a single PHP script ("phinx"). Thus, I would need to check which variant is installed to make my application platform-independent (phinx is called from within the application).

I use the same working copy (in Windows via network share) and the same composer version (1.4.1) in both operating systems. Installed phinx version is 0.9.1.

_Update:_

Apparently, Composer for Windows generates the shell script, see https://getcomposer.org/doc/articles/vendor-binaries.md#what-about-windows-and-bat-files-. So this is no problem of phinx.

Hello,
After running this command to migrate vendor\bin\phinx migrate -c config-phinx.php
I am getting the following error

`Phinx by Rob Morgan - https://phinx.org. 0.5.5

using config file .\config-phinx.php
using config parser php
using migration path migrations
warning no environment specified, defaulting to: dev
using adapter mysql
using database cymour
PHP Fatal error: Class 'MyProject\Migration\Migration' not found in C:\xampp\htdocs\demo\migrations\20171024054328_my_first_migration.php on line 5
PHP Stack trace:
PHP 1. {main}() C:\xampp\htdocs\demo\vendor\robmorgan\phinx\bin\phinx:0
PHP 2. Symfony\Component\Console\Application->run() C:\xampp\htdocs\demo\vendor\robmorgan\phinx\bin\phinx:28
PHP 3. Phinx\Console\PhinxApplication->doRun() C:\xampp\htdocs\demo\vendorsymfony\console\Application.php:125
PHP 4. Symfony\Component\Console\Application->doRun() C:\xampp\htdocs\demo\vendor\robmorgan\phinxsrc\Phinx\Console\PhinxApplication.php:82
PHP 5. Symfony\Component\Console\Application->doRunCommand() C:\xampp\htdocs\demo\vendorsymfony\console\Application.php:224
PHP 6. Symfony\Component\Console\Command\Command->run() C:\xampp\htdocs\demo\vendorsymfony\console\Application.php:888
PHP 7. Phinx\Console\Command\Migrate->execute() C:\xampp\htdocs\demo\vendorsymfony\console\Command\Command.php:262
PHP 8. Phinx\Migration\Manager->migrate() C:\xampp\htdocs\demo\vendor\robmorgan\phinxsrc\Phinx\Console\Command\Migrate.php:113
PHP 9. Phinx\Migration\Manager->getMigrations() C:\xampp\htdocs\demo\vendor\robmorgan\phinxsrc\Phinx\Migration\Manager.php:240
PHP 10. require_once() C:\xampp\htdocs\demo\vendor\robmorgan\phinxsrc\Phinx\Migration\Manager.php:549

Fatal error: Class 'MyProject\Migration\Migration' not found in C:\xampp\htdocs\demo\migrations\20171024054328_my_first_migration.php on line 5

Call Stack:
0.0002 345280 1. {main}() C:\xampp\htdocs\demo\vendor\robmorgan\phinx\bin\phinx:0
0.0188 1504936 2. Symfony\Component\Console\Application->run() C:\xampp\htdocs\demo\vendor\robmorgan\phinx\bin\phinx:28
0.0636 1748200 3. Phinx\Console\PhinxApplication->doRun() C:\xampp\htdocs\demo\vendorsymfony\console\Application.php:125
0.0646 1748200 4. Symfony\Component\Console\Application->doRun() C:\xampp\htdocs\demo\vendor\robmorgan\phinxsrc\Phinx\Console\PhinxApplication.php:82
0.0648 1748200 5. Symfony\Component\Console\Application->doRunCommand() C:\xampp\htdocs\demo\vendorsymfony\console\Application.php:224
0.0649 1748200 6. Symfony\Component\Console\Command\Command->run() C:\xampp\htdocs\demo\vendorsymfony\console\Application.php:888
0.0659 1753008 7. Phinx\Console\Command\Migrate->execute() C:\xampp\htdocs\demo\vendorsymfony\console\Command\Command.php:262
0.0760 1918680 8. Phinx\Migration\Manager->migrate() C:\xampp\htdocs\demo\vendor\robmorgan\phinxsrc\Phinx\Console\Command\Migrate.php:113
0.0760 1918680 9. Phinx\Migration\Manager->getMigrations() C:\xampp\htdocs\demo\vendor\robmorgan\phinxsrc\Phinx\Migration\Manager.php:240
0.0773 1941792 10. require_once('C:\xampp\htdocs\demo\migrations\20171024054328_my_first_migration.php') C:\xampp\htdocs\demo\vendor\robmorgan\phinxsrc\Phinx\Migration\Manager.php:549`

Can you please help me out. I am working on windows OS

Voc锚 est谩 no windows? Tente sem php e use separadores de janelas:
vendor\bin\phinx init

Thanks my friend, i'm just 2 weeks tryng to solve this error!!! it works 4 me

Was this page helpful?
0 / 5 - 0 ratings

Related issues

doctordesh picture doctordesh  路  4Comments

Jacco-V picture Jacco-V  路  4Comments

resgef picture resgef  路  5Comments

amcoho picture amcoho  路  4Comments

elct9620 picture elct9620  路  4Comments