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
Related
I've recently installed laravel and have written some tests in /tests directory but when I use phpunit at cmd in the same folder that phpunit.xml exists, it says 'phpunit' is not recognized as an internal or external command,operable program or batch file.. I'm using windows 7. what should I do?
The solution for me:
php vendor/phpunit/phpunit/phpunit
This, of course, assumes you've set up a php environment variable in Windows
As Unnawut said, it doesn't work because vendor/phpunit/phpunit/phpunit is not a native Windows executable. You need a .bat or .cmd file that will basically call 'php phpunit'. There should be one in vendor/bin, but to make life easy, try this - create a file phpunit.bat (or .cmd) at the root of your site, containing this:
#ECHO OFF
SET BIN_TARGET=%~dp0/vendor/phpunit/phpunit/phpunit
php "%BIN_TARGET%" %*
Now you can call phpunit from the command line at the root of the site.
If you are a window user and you are having this issue, do this:
You need to tell Window where to find PHPUnit command, you can first of all verify that this file exists in your Laravel project under /vendor/bin
Finally you need to append the full path to /vendor/bin in your window PATH variable,
To do this:
1. Right-click on 'Computer' then click properties
On the second window click Advanced system settings
On the next window under Advanced click Environmental Variables
On the next window double-click PATH then set PATH variable by appending
the full path to your laravel-project/vendor/bin; Notice the ; at the end.
NB: Other variables might already exists in the PATH, so ensure you don't overwrite them by appending your own at the very end
Finally click Ok on all the dialog boxes
alias phpunit="vendor/bin/phpunit"
I added this command in command line instead of just "phpunit"
vendor\bin\phpunit
That worked for me.
Install phpunit globally:
composer global require phpunit/phpunit
Afterwards you will be able to run phpunit ( even on Windows ):
phpunit
The phpunit executable is not in your project root folder, that's why it can't find it.
Now I assume that you already have phpunit in your composer.json file, something like this:
"require-dev": {
"phpunit/phpunit": "3.7.*"
}
When installed by composer, the package will be installed to vendor/vendor_name/package_name. So to run it at your project root, type this command:
vendor/phpunit/phpunit/phpunit
Borrowing from #Chris' excellent answer:
Even better, you can make vendor/phpunit/phpunit/phpunit an environment variable, say "phpunit" and whenever you want to run the test in any laravel project you just call php %phpunit%.
Demonstration
This working for me
In double quotes this command in console windows
"vendor/bin/phpunit"
If it says the following:
$ phpunit tests/Feature/ExampleTest.php
PHPUnit 3.7.21 by Sebastian Bergmann.
Class 'tests/Feature/ExampleTest' could not be found in 'C:\xampp\htdocs\blog1\tests\Feature\ExampleTest.php'.
Instead of typing tests/Feature/ExampleTest.php you say tests " \\Feature\\Example.test" because you're using windows, not mac. :) GL & HF
Using just \ or / will give errors :)
With Laravel phpunit is set up right out of the box. The easiest way to run it on Windows is to add an entry to scripts in your package.json file...
"scripts": {
...
"tests": "php vendor/phpunit/phpunit/phpunit"
},
Now you simply run unit tests with
npm run tests
I've read the global installation documentation for Composer, but it's for *nix systems only:
curl -s https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
I would be such happy doing the same on Windows, that's the OS of my development machine. I would be able to run
composer update
From an arbitrary folder where composer.json exists. Interpreter php.exe is already in PATH variable.
Any clue?
Sure. Just put composer.phar somewhere like C:\php\composer.phar, then make a batch file somewhere within the PATH called composer.bat which does the following:
#ECHO OFF
php "%~dp0composer.phar" %*
The "%*" repeats all of the arguments passed to the shell script.
Then you can run around doing composer update all ya want!
Install Composer
On Windows, you can use the Composer Windows Installer.
Go to php.exe located folder.
C:\wamp\bin\php\php5.5.12\
open cmd there, and execute below command.
php -r "readfile('https://getcomposer.org/installer');" | php
composer.phar will be downloaded in same folder.
Create folder named composer in C:// drive (or anywhere you wish, for upcoming steps, remember the path).
move composer.phar file to C://composer folder.
Create composer.bat file in same folder with contents below
#ECHO OFF
php "%~dp0composer.phar" %*
create file named composer without any extensions.
running command type NUL > composer in CMD will help to get it done quickly,
Open that file and place below contents inside it.
#!/bin/sh
dir=$(d=$(dirname "$0"); cd "$d" && pwd)
# see if we are running in cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
# cygwin paths start with /cygdrive/ which will break windows PHP,
# so we need to translate the dir path to windows format. However
# we could be using cygwin PHP which does not require this, so we
# test if the path to PHP starts with /cygdrive/ rather than /usr/bin.
if [[ $(which php) == /cygdrive/* ]]; then
dir=$(cygpath -m $dir);
fi
fi
dir=$(echo $dir | sed 's/ /\ /g')
php "${dir}/composer.phar" $*
Save.
Now set path, So we can access composer from cmd.
Show Desktop.
Right Click My Computer shortcut in the desktop.
Click Properties.
You should see a section of control Panel - Control Panel\System and
Security\System.
Click Advanced System Settings on the Left menu.
Click Environment Variables towards the bottom of the window.
Select PATH in the user variables list.
Append your PHP Path (C:\composer) to your PATH variable, separated
from the already existing string by a semi colon.
Click OK
Restart your machine.
Or, restart explorer only using below command in CMD.
taskkill /f /IM explorer.exe
start explorer.exe
exit
Original Article with screenshots here : http://aslamise.blogspot.com/2015/07/installing-composer-manually-in-windows-7-using-cmd.html
This may be useful to someone:
On Windows 7, if you've installed Composer using curl, it can be found in similar path:
C:\Users\<username>\AppData\Roaming\Composer
Well, now this question is a bit obsolete as there is now an official installer which "will install the latest Composer version and set up your PATH so that you can just call composer from any directory in your command line."
You can get it at : http://getcomposer.org/doc/00-intro.md#installation-windows
A bit more generic if you put the batch in the same folder as composer.phar:
#ECHO OFF
SET SUBDIR=%~dp0
php %SUBDIR%/composer.phar %*
I'd write it as a comment, but code isn't avail there
Start > Computer : Properties > Change Settings > Advanced > Environment Variables > PATH : Edit [add this string (without "") at the end of line ";C:\<path to php folder>\php5.5.3"].. open cmd and type composer
thats it :-)
I use Composer-Setup.exe and it works fine.
Just in case you need to know where is the composer.phar (to use with PhpStorm) :
C:\ProgramData\ComposerSetup\bin\composer.phar
Unfortunately, all the good answers here didn't work for me. So after installing composer on windows 10, I just had to set system variable in environment variables and it worked.
sorry to dig this up, I just want to share my idea, the easy way for me is to rename composer.phar to composer.bat and put it into my PATH.
An alternative variant (see Lusitanian answer) is to register .phar files as executable on your system, exemplary phar.reg file:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.phar]
#="phar_auto_file"
[HKEY_CLASSES_ROOT\phar_auto_file\shell\open\command]
#="\"c:\\PROGRA~1\\php\\php.exe\" \"%1\" %*"
Just replace the path to php.exe to your PHP executable. You can then also extend the %PATHEXT% commandline variable with .PHAR which will allow you to type composer instead of composer.phar as long as composer.phar is inside the %Path%.
I was having the same issue and when I checked the environment in Windows 7 it was pointing to c:\users\myname\appdata\composer\version\bin which didn't exists.
the file was actually located in
C:\ProgramData\ComposerSetup\bin
Fixed the location in environment setting and it worked
you can install it using this command line
echo #php "%~dp0composer.phar" %* > composer.bat
I found that on Control Panel > Environment Variables > Variables for my localuser just inside PATH varible like this:
C:\Users\MY_USER_NAME\AppData\Roaming\Composer\vendor\bin
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.
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