I am learning Symfony, so I have only gotten to
Symfony/web/app_dev.php/demo/
But I'm still not able to find how to use command line.
I have shell access, but where to execute this command?
php app/console generate:bundle --namespace=Blogger/BlogBundle --format=yml
That command is meant to be run from your root symfony folder. If you have everything installed correctly, you should see the app directory listed when you use the ls command. If you don't see the app directory, either you didn't install correctly or your in the wrong folder on your system.
execute from root folder. The "console" (its a php file with no extension) file is in app/ folder. You can also go into that folder and run:
php console generate:bundle --namespace=Blogger/BlogBundle --format=yml
Related
I'm currently developing a PHP application using Symfony and Doctrine. My goal at this point is to create a bash script to build my database schema and load fixtures. My current script lives in the /bin folder and has the following content:
#!/usr/bin/env bash
php bin/console doctrine:migrations:migrate
php bin/console doctrine:fixtures:load --purge-with-truncate
The script is executable and when I try to run it (./create_de.sh), I get the following error:
Could not open input file: bin/console
I tried to change the script to be the following:
#!/usr/bin/env bash
php console doctrine:migrations:migrate
php console doctrine:fixtures:load --purge-with-truncate
But I still get the same error, except without the bin part.
When I run the commands in the script via command line I have no problems. Any idea why this script doesn't work?
have you tried (from within bin/) dos2unix create_de.sh > create_de_new.sh, then ./create_de_new.sh?
Did you check your permissions, the file bin/console must to have execution permissions:
Something like:
chmod +x bin/console
Since the script lives inside the bin folder, just change it to:
php ./console doctrine:migrations:migrate
php ./console doctrine:fixtures:load --purge-with-truncate
Edit: there isn't any permissions issue here as other comments suggest, as the permissions of the console file are by default -rwxr-xr-x which means everyone can execute it.
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...
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
Add php to your Path Environment Variable so that you can execute php from the command line
(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
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.
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.
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
i followed an online tutorial on integrating doctrine 2 and ZF2. i am able to insert data to database but whenever i run doctrine CLI it outputs:
#!/usr/bin/env sh
SRC_DIR="`pwd`"
cd "`dirname "$0"`"
cd "../doctrine/orm/bin"
BIN_TARGET="`pwd`/doctrine.php"
cd "$SRC_DIR"
"$BIN_TARGET" "$#"
which is the content to doctrine.php that i replaced with codes frome tutorial.
I found this on another question here and it works on Windows.
There are also a bin folder in vendor/doctrine/orm/bin/ you can use this one like this in your console commands:
php vendor/doctrine/orm/bin/doctrine orm:schema-tool:create
Copy the path to doctrine binaries (containing "doctrine", "doctrine.php", "doctrine.bat"...
Go to the root of your project, and type:
php path_to_doctrine_bin/doctrine.php [options]
That should do it.
On Windows, you need to run the .bat files instead. eg.
vendor\bin\doctrine.bat orm:schema-tool:create
Face the same problem , it turns out using forward slash instead of backward slash was the real culprit
So move inside the project directory and do
vendor\bin\doctrine.bat orm:schema-tool:create
What works for me is to use the original shell/bash script in the vendor dir (running on win7)
$ vendor/doctrine/orm/bin/doctrine orm:schema-tool:create
I installed wamp server and a copy of the Symfony2 framework. I am trying to create a Bundle, using the following command:
php app/console generate:bundle --nampespace=IDP/IDP_Bundle --format=yml
My PHP is in C:/wamp/bin/php/php5.3.10
But when I run the command it says:
could not open input file app/console
Can anyone tell me what is going wrong?
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.
Dont run the command from the php path.
Add php into your path environment variable
and then cd to the project
C:/wamp/www/yourproject
and then run the command
php app/console generate:bundle --nampespace=IDP/IDP_Bundle --format=yml
It will work
For newer versions of Symfony (2.4.x or newer) use this method on windows to resolve the problem:
Go to project directory e.g. d:/xampp/symfony2-project/ and open composer.json and place this under requires array "symfony/console": "2.4.*#dev". And save the file.
Open command-line and cd to project's directory.
Use this command to let download and install the dependencies: php path/to/composer.phar install. Remember you should be in your project's directory and path/to/composer.phar is the actual path to your composer.phar file.
Now you are all done, just use php bin/console generate:bundle --namespace=Test/PrintBundle --format=yml
Actually You need to be in your project root to run this command and you have to add php directory to your system env path variable.
Add your php directory to the system path variable
cd to the root of your project
I'm use Symfony 3 and the Bundle calendar-bundle.
This error is present in the documentation of: Bundle: https://github.com/adesigns/calendar-bundle
The form correct is:
php bin/console assets:install web
Regards
First check the Environment Variable which is in Advanced system setting -> set path of C:/wamp/www/bin/php and then
run cmd->go to the directory of your project which is in www folder using cd C:/wamp/www/yourproject
use then user php app/console that shows the all command.
Sounds like you (i.e., your user) don't have access to read/execute console. I've never worked with with file permissions on a WAMP stack so I'm not sure what you'll need to do to fix them.
I got the same issue when installing the pear library
my issue was, when downloading the go-pear.phar file, it downloads as the (.txt) extension which i didn't see.
jst change the file extension to .phar and run the code
It is also possible that you have the line :
//umask(0000);
in your /web file, app_dev.php.
If after doing :
php app/console generate:bundle --nampespace=IDP/IDP_Bundle --format=yml
in your project path, you still can not generate your bundle, try uncommenting the unmask line. It worked for me.
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.
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.
Most probably, you're not in the symfony2 project directory.
start the windows console as you're doing it (Start->Run->CMD)
then move to the symfony2 project root directory with the command cd:
"cd c:\htdocs\path\to\your\symfony2\project"
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.