PHP app\\console wont work trying to create bundle

2020-07-30 03:45发布

问题:

I have installed Symfony2 on a Xampp server with PHP 5.3.8 and everything works ok ( the php, the symfony demo page ).

I try to create my own helloWorld, as the tutorial says :

php app/console generate:bundle --namespace=Acme/HelloBundle --format=yml

I go Start->Run->CMD and put that line of code and it gives me back this :

could not open input file : app/console

I put the PHP directory to the System PATH but the problem persists.

回答1:

To execute command you should move to root directory of your project in terminal/CMD.

Please note that in version 2.5 some changes has been made so command will not work with app/console

Note: From 2.5 app/console is replaced by bin/console.

Please check here for changes. Also check this for more details about difference.



回答2:

Most probably, you're not in the symfony2 project directory.

  1. start the windows console as you're doing it (Start->Run->CMD)
  2. then move to the symfony2 project root directory with the command cd: "cd c:\htdocs\path\to\your\symfony2\project"
  3. then run the command from the tutorial

the thing is that the part of the command from the tutorial "app/console" means the path to the "console" script in the "app" directory of the symfony2 project.