4

Recently I started working with Symfony2. Unfortunately the php app/console commands doesn't work at both my MAMP server as Vagrant server (MAC OSX). I tried to make a bundle with the following command

php app/console generate:bundle --namespace=Vendor/NameBundle

and also tried to fix a problem with

php app/console assets:install web

And both commands returned the following in my terminal:

Could not open input file: app/console

Does someone know how to fix this problem? I AM working at my project directory like: mac/applications/mamp/htdocs/project but it is still not working. I also tried to reinstall a new symfony project but that was not a fix. I guess my php isn't working at all in my terminal...

Giesburts
  • 6,879
  • 15
  • 48
  • 85
  • can you execute any command-line php script at all ? – Calimero Dec 02 '15 at 14:50
  • You run that command from project directory, right? – Kristian Vitozev Dec 02 '15 at 14:50
  • just type `php` and press return, what happens ? – john Smith Dec 02 '15 at 14:53
  • Possible duplicate of [Could not open input file app/console](http://stackoverflow.com/questions/10637230/could-not-open-input-file-app-console) – HPierce Dec 02 '15 at 15:00
  • @vitozev Yes, like glenngijsberts/applications/MAMP/htdocs/symfony2 right? – Giesburts Dec 02 '15 at 15:15
  • The problem is that you downloaded the latest symfony which, as of two days ago, is 3.0. app/console has been changed to bin/console. Reinstall your symfony project making sure you specify 2.8. You probably don't want to get involved with 3.0 at this point. And whenever you browse the documentation make sure you select '2.8' instead of 'latest', – Cerad Dec 02 '15 at 15:15
  • @johnSmith Nothing.. returns nothing and not even returns my command line.. – Giesburts Dec 02 '15 at 15:16
  • @Cerad Yes, thought so, but unfortunealy I cant even make a bundle in my older projects with version 2.7.6 – Giesburts Dec 02 '15 at 15:19
  • Might be a permission issue: chmod +x app/console though you really should not need to do that. And verify that app/console actually exists. It's just a file. Maybe you installed the project as a different user? – Cerad Dec 02 '15 at 15:24

3 Answers3

10

So the problem was the version number. Symfony version 3.0 is available now so if you're do not selecting a version number at your project install it will automaticly install version 3.0 instead of 2.7. The new command is:

$ php bin/console generate:bundle --namespace=Vendor/NameBundle

instead of

$ php app/console generate:bundle --namespace=Vendor/NameBundle
Giesburts
  • 6,879
  • 15
  • 48
  • 85
3
  1. Add php to your Path Environment Variable so that you can execute php from the command line
  2. (You may need to restart your computer after step 1) From the command line type: php -version to test whether php has successfully been added to your pathenvironment variable
  3. Depending on the version of Symfony you have, you will need to execute either php app/console or php bin/console where console is a php file inside the app or bin directories in your project root. To check which command to use, look into your project directories, if bin/ directory is present then execute php bin/console as console.php is located in that directory.
  4. From the command line, cd into your project root directory and run the appropriate command as mentioned above. To check whether you are in the correct directory, run the dir command, if all your Symfony project directories: app/, bin/, src/, vendors/ etc. are displayed, then the php app/console (bin/console) ... command should run successfully.
Charles
  • 320
  • 2
  • 8
0

or just create a new 2.8.x symfony project using:

symfony new yourAppName 2.8

instead of:

symfony new yourAppName

(which would create a new 3.x symfony project)

in this way you will be able to use:

php app/console

Francesco Borzi
  • 56,083
  • 47
  • 179
  • 252