Phinx: Symfony\Component\Console\Exception\LogicException

Created on 26 Aug 2019  路  9Comments  路  Source: cakephp/phinx

Hello guys

I just started to get this exception while running Phinx :

PHP Fatal error: Uncaught SymfonyComponentConsoleExceptionLogicException: The command defined in "PhinxConsoleCommandInit" cannot have an empty name. in /var/lib/jenkins/workspace/hqbeds-dev-php7/vendor/symfony/console/Command/Command.php:453
Stack trace:

0 /var/lib/jenkins/workspace/hqbeds-dev-php7/vendor/robmorgan/phinx/src/Phinx/Console/Command/Init.php(47): SymfonyComponentConsoleCommandCommand->getName()

1 /var/lib/jenkins/workspace/hqbeds-dev-php7/vendor/symfony/console/Command/Command.php(77): PhinxConsoleCommandInit->configure()

2 /var/lib/jenkins/workspace/hqbeds-dev-php7/vendor/robmorgan/phinx/src/Phinx/Console/PhinxApplication.php(60): SymfonyComponentConsoleCommandCommand->__construct()

3 /var/lib/jenkins/workspace/hqbeds-dev-php7/vendor/robmorgan/phinx/app/phinx.php(36): PhinxConsolePhinxApplication->__construct()

4 /var/lib/jenkins/workspace/hqbeds-dev-php7/vendor/robmorgan/phinx/bin/phinx(27): require('/var/lib/jenkin...')

5 {main}

thrown in /var/lib/jenkins/workspace/hqbeds-dev-php7/vendor/symfony/console/Command/Command.php on line 453

I was using version 0.10.6 when I got the error. I tried upgrading to 0.10.8 , but still the same problem.

My php version is PHP 7.3.7

It was running okay 3 hours ago...

Can anyone help me?

Most helpful comment

Looks like Symfony's Command::getName() was never intended to return null, but it worked in Phinx because types were not enforced (they were only declared using PHPdocs). It is my understanding that for its version 5 Symfony intends to enforce its type returns.

So preparing a fix for Phinx seems to me to be the best approach, as it immediately solves the issue and prepares for the future. I've created a PR for it, please have a look a leave a comment if you see it fit.

All 9 comments

Here broke SymfonyComponentConsoleCommandCommand::getName
https://github.com/symfony/console/commit/4510f04e70344d70952566e4262a0b11df39cb10#diff-25a75e093c4a0d5564a36cebbb1384b3R461

I got crazy trying to figure out what is the problem. It's a relief to see that it's not just in my head.
What should we do then? downgrade phinx?
Thanks

Force the version of symphony/console in your composer.json untill they fix it with
"symfony/console": "v3.4.27"
I did that here...

Is there a reasonable fix on cake's side?
Can the method be made to return a name?

You have to set ne name of the command in PhinxApplication.php:59
$this->addCommands([
new CommandInit('init'),
new CommandCreate('create'),
new CommandMigrate('migrate'),
new CommandRollback('rollback'),
new CommandStatus('status'),
new CommandBreakpoint('breakpoint'),
new CommandTest('test'),
new CommandSeedCreate('seedcreate'),
new CommandSeedRun('seedrun'),
]);

Or fix the console version : "symfony/console": "v3.4.27"

@Xakki Based on https://github.com/symfony/console/commit/4510f04e70344d70952566e4262a0b11df39cb10 you can make a fix on symfony/console to revert the bad change and allow nullable (including documented |null).

Looks like Symfony's Command::getName() was never intended to return null, but it worked in Phinx because types were not enforced (they were only declared using PHPdocs). It is my understanding that for its version 5 Symfony intends to enforce its type returns.

So preparing a fix for Phinx seems to me to be the best approach, as it immediately solves the issue and prepares for the future. I've created a PR for it, please have a look a leave a comment if you see it fit.

Your PR https://github.com/cakephp/phinx/pull/1588 indeed seems quite future proof
Nice one!

Force the version of symphony/console in your composer.json untill they fix it with
"symfony/console": "v3.4.27"
I did that here...

good idea

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ricksanchez picture ricksanchez  路  15Comments

alex-barylski picture alex-barylski  路  14Comments

igorsantos07 picture igorsantos07  路  30Comments

joshribakoff picture joshribakoff  路  15Comments

saada picture saada  路  14Comments