I'm running php composer.phar install from git bash CLI and it shows sh:php: Command not found.
Though I have set environment variable path to my wamp/bin/php/php5.4.16/
You are required to put the directory that has php.exe in your WAMP installation into environment variable PATH. It is generally like C:\wamp\bin\php.
Where \php\ is the directory containing php.exe.
Set php env. variable as mentioned here. (you can test it easily using this command: php -r "echo 1;" or php -v)
restart git shell
if composer.phar does not exists, run this (more info):
php -r "readfile('https://getcomposer.org/installer');" | php
run php composer.phar install finally
Run php without git shell:
Locate C:\wamp\bin\php
Hold SHIFT and click with right mousebutton on folder phpX.Y.ZZ
Select Open command prompt window here
run any php command like php parameters
Whether you are using gitbash or cmd you should run it as an administrator. Navigate to your project then type the command "composer install" it will work. Mine worked just fine.
Related
Successfully install composer with their instruction but I can't check composer version. I also add path in environment. Which things left that I need to do?
User Variables
System Variables
Command line
Check if using this command works for you:
php C:\ProgramData\ComposerSetup\bin\composer.phar -v
If this is working and there is a missing composer.bat file in C:\ProgramData\ComposerSetup\bin you'll have to create it manually with this content:
#echo off
php "%~dp0composer.phar" %*
Then you'll be able to use composer -v instead of php C:\ProgramData\ComposerSetup\bin\composer.phar -v in your Command Prompt.
I'm assuming that you could execute php scripts and you already added the correct path to your system, because if composer.bat is not missing and you didn't add the path to your php executables, then this is the reason for this composer issue in the first place.
I'm trying to install Laravel Homestead in order to be able to test my Laravel projects locally.
I'm following this tutorial: http://laravel.com/docs/4.2/homestead
In the "Installing Homestead" part I followed the second step "Manually Via Git (No Local PHP)",I don't have any PHP installed locally and can't use Composer. (Wasn't PHP supposed to be installed as part of Homestead?)
I got to this part:
Once you have installed the Homestead CLI tool, run the bash init.sh command to create the Homestead.yaml configuration file:
bash init.sh
In command prompt I tried to enter the following command:
bash init.sh
I got the following error:
'bash' is not recognized as an internal or external command, operable program or batch file.
Then I tried to enter the same command in Git Bash, and I got the following error:
bash: init.sh: No such file or directory
When I tried to enter in Git Bash simply
init.sh
I got the following error:
sh.exe": init.sh: command not found
I ran into this problem well. You need to hop into your terminal (I am on Mac.)
Type into your console: cd ~/Homestead
and to make sure you are in your newly generated Homestead folder (you can always click Finder > your home directory > Homestead to confirm it's where it should be),
then while in terminal simply type ls -- if it lists all of the files like Vagrantfile, composer.lock and bash init.sh, you should be in.
Once you know you are in the correct Homestead folder, it is now at that point in which you run bash init.sh
After doing this it now says Homestead initialized!
.sh is a unix/linux script executable, that isn't recognized on Windows. There's a init.bat included in the package, but it isn't referenced in the tutorial.
Just run init.bat from the command line. It will copy the files to:
%HOMEDRIVE%%HOMEPATH%\.homestead
You need install Git Bash, and then run commands into Git Bash.
Try init.bat that worked for me
If the init.bat refused to work
Go to the Homestead folder.
C:/Users/Computer Name/Homestead
You will see init.bat: double click to run it.
Problem solved.
I found the answer you may be looking for. I was having the same problems with this. Just make sure at the end of bash init.sh you put a ;
So in the git bash cmd you will have this line
$ bash init.sh;
Just do it using sudo.
$sudo bash init.sh
I'm getting an error saying:
failed to clone https://github.com/php-fig/log.git, git was not found, check that it is installed and in your PATH env.
'git' is not recognized as and internal or external command, operable program or batch file
when I try and run composer create-project laravel/laravel learning-laravel.
I installed the git GUI which also comes with a command line shell, but I don't know why its not recognising the command (I'm issuing the create-project command in the normal windows command line prompt).
I also tried running the command from the git shell, which worked, but when I tried php artisan serve it gave me an error saying CLI has stopped working.
Does anyone know how to fix the git error? I'd rather use the windows command shell instead of the git one as it can then go into my wamp/www file
You need to add the directory you installed git to to your PATH environment variable.
Right click on Computer.
Click Advanced System Settings
Click Environment Variables inside the Advanced Menu
Under System Variables, scroll to PATH
Add ;"C:\path\to\git\bin";"C:\path\to\git\cmd"
Test the git command in the command prompt to see if it worked. Git is usually located in Program Files or Program Files(x86).
There is an easier (but temporal) way to add a path variable in Windows.
Paste this in your command prompt:
SET PATH=%PATH%;C:\Program Files\Git\bin
This will work for the rest of the command prompt session. Don't forget installing Git before this.
You'll need to add git to your system PATH if you want to use it in regular command prompt.
Here's a guide on modifying your system path in Windows:
http://www.computerhope.com/issues/ch000549.htm
you need to uninstall git and reinstall ( or update ) in the options you need to change from git bash only to allow git to be added to command line as well, also since it then adds it to your path you may or may not need to restart your computer
I was having some issues using git on Windows. I found this information only and it worked for me.
http://ccn.ucla.edu/wiki/index.php/Setting_Up_and_Using_Git#Windows
I am currently working with symfony2 and I want to launch to download the libraries I need. I know the command in linux is "$ ./composer.phar update --dev" however when I run this in windows it prompts whether I should open the file with the windows explorer or not. I currently have composer.phar installed on windows but I am having trouble launching it. How would I be able to update my symfony2 folder with the dependencies I need. Thank you.
In CMD:
php C:\ProgramData\ComposerSetup\bin\composer.phar self-update
The problem is that Windows don't know how to open .phar files. You need to execute them using php interpreter php composer.phar update and the php interpreter(php.exe) must be accessible on PATH.
You could use command php -v to check if your php is accessible from command line.
Go to C:\ProgramData\ComposerSetup\bin\composer.phar
In CMD write php composer.phar (update) or (self-update)
1: Open cmd
First go to your work directory like if you have wamp then c:/wamp/www.
Then enter composer if you can see list of composer command then its good.
Now type "composer self-update".
5: Next you can see the process.
This worked for me on my Centos server
sudo -u nginx php composer.phar update
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