Symfony CLI arguments are interpreted by PHP
I am trying to import a database structure for mapping from Symfony / Doctrine.
I followed the tutorial here and gives the command to create mapping files from existing databases:
php app/console doctrine:mapping:convert xml ./src/Acme/BlogBundle/Resources/config/doctrine/metadata/orm --from-database --force
But the PHP interpreter exits instantly:
PHP Fatal error: Option inconnue --from-database in Unknown on line 0
Could not startup.
( Option inconnue
means unknown in French)
I understand that PHP does not pass arguments to the app / console script.
If I try with HHVM , the arguments are sent to the PHP script (so that's ok).
PHP version: PHP 5.5.12-2ubuntu4.1
EDIT: Problem solved, see my answer below. I'll be accepting it tomorrow (StackOverflow limitation).
source to share
Because of the shebang in the console script, you can omit the php interpreter call on the command line by running:
chmod +x app/console
./app/console doctrine:mapping:convert xml ./src/Acme/BlogBundle/Resources/config/doctrine/metadata/orm --from-database --force
or alternatively you can do:
php app/console -- doctrine:mapping:convert xml ./src/Acme/BlogBundle/Resources/config/doctrine/metadata/orm --from-database --force
Notice the extra splitting --
after the input file name script, which tells the php interpreter that each subsequent argument should be cast to the script.
source to share
The problem has been resolved.
sudo apt-get purge php5-cli
sudo apt-get install php5-cli
It seems that the person had the same problem and some people suggested that the php.ini is missing.
So I reinstalled PHP and now it works fine.
If anyone has an explanation for this behavior, it would be great!
EDIT: Hmm, no, there is a problem. It worked great until I added my extensions to php.ini. I added two lines:
extension=cairo.so
extension=php_gtk2.so
And now it's broken again ...: /
source to share