Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fatal error: Class 'Symfony\Component\Console\Input\ArgvInput' not found in app/console on line 16

Tags:

I got a working symfony app, today I decided to do a composer update

the result of the composer update can ben found here https://github.com/allan-simon/oauth2-symfony2-vagrant-fosuserbundle/commit/dfa25593f79c5595ca4759803ec1e998091c68b9 (mostly change in minor version, note there's a change in version of symfony, but keeping it to 2.6 produce also the problems below)

And now after the upgrade I got this error

Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception

[RuntimeException]                                                                                                   An error occurred when executing the "'cache:clear --no-warmup'" command:                                            PHP Fatal error:  Class 'Symfony\Component\Console\Input\ArgvInput' not found in /vagrant/app/console on line 16     .    
  • The content of the app/console has not changed
  • I've tried deleting and recreating the bootstrap.cache no change
  • In my vendor directory, I do have said ArgvInput class

Any idea on what can the problem be ?

like image 689
allan.simon Avatar asked Nov 29 '15 14:11

allan.simon


People also ask

How to pass arguments to the constructor in Symfony?

When passing an argument to the constructor, be sure that it respects the same rules as the argv one. It's almost always better to use the StringInput when you want to provide your own input. Symfony\Component\Console\Input\Input implements Symfony\Component\Console\Input\InputInterface Constructor. Constructor. Processes command line arguments.

When to use argv vs stringinput in Symfony?

When passing an argument to the constructor, be sure that it respects the same rules as the argv one. It's almost always better to use the StringInput when you want to provide your own input. Symfony\Component\Console\Input\Input implements Symfony\Component\Console\Input\InputInterface

Why doesn't the command run if the argument is not provided?

The command doesn't run if the argument isn't provided; The argument is optional and therefore can be omitted. This is the default behavior of arguments; The argument can contain any number of values. For that reason, it must be used at the end of the argument list.

How to avoid ambiguous command names in Symfony?

For example, php bin/console --iterations 5 app:greet Fabien is ambiguous; Symfony would interpret 5 as the command name. To avoid this situation, always place options after the command name, or avoid using a space to separate the option name from its value.


1 Answers

The problem was caused because my composer.json had the line

"sensio/distribution-bundle": ">=2.3.7", 

So it was updating to the latest version (5.x at the time of writing) which is incompatible with the files structure of symfony 2.7 and below projects

instead I've put the line

"sensio/distribution-bundle": "~4.0", 

and now it's working fine

more explanation here

https://github.com/sensiolabs/SensioDistributionBundle/issues/243

like image 181
allan.simon Avatar answered Nov 07 '22 21:11

allan.simon