I've installed a fresh copy of High Sierra today (After resetting my whole mac) so now I am at the point of installing all things related to programming, like the Laravel installer for now.
I have problems with installing the laravel installer and with the path I suppose.
I know there are a lot of questions a bit similiar to this but for some reason I haven't found the right answer yet.
So as the documentation of Laravel said I installed composer and that works just fine. After that I installed the Laravel installer with composer. I placed the command(?) for my path in the .bashrc file but after a re open of my terminal the command Laravel was not found. I knew from previous times this thing was a pain in the ass and I am also not very familiar with all those things in the command line so this is kinda hard for me.
What I did:
1) I installed composer. After that, I did mv composer.phar /usr/local/bin/composer in my terminal. Also I did mkdir -p /usr/local/bin because i had a fresh install so those directories were not found of course, because they didn't exist.
2) After that I ran composer global require "laravel/installer" in my terminal. This was all going great.
3) Last step was to do this thing with the PATH. I still don't know if I did this right. What I did was nano ~/.bashrc and then added export PATH=~/.composer/vendor/bin:$PATH to this file. This did not work, so I still can't use Laravel .. in my terminal. I don't know much about this source command but when I do source ~/.bashrc I can use this Laravel command but when I open a new tab or window I can't use it anymore.
4) Besides export PATH=~/.composer/vendor/bin:$PATH in the .bashrc file I also tried export PATH="$HOME/.composer/vendor/bin:$PATH" in that file. that doesn't work either.
Is there someone that can help me out? Good to know is that I just installed a fresh copy of OS and did nothing besides installing some normal programms. Laravel/Composer were my first things with the terminal.
It might be that your terminal program is set to create a login shell, which doesn't source ~/.bashrc
Try adding this to ~/.bash_profile
[[ -f ~/.bashrc ]] && . ~/.bashrc
I have installed Composer locally only for one Laravel project
~/phpstorm/myproject/composer.phar
and didn't have any problem till I tried to create a new Laravel project, then I got an error:
Could not open input file: composer.phar
I tried to add the .phar file directly to the PATH, but it doesn't seem to change anything.
PATH=~/phpstorm/myproject/composer.phar:$PATH
Does somebody know how I could manage this problem without installing Composer globally? In the Internet I only found this easiest kind of solution, but it doesn't suit me, alas.
Thanks for your proposals in advance!
Change the name from composer.phar to composer by this command:
mv composer.phar composer, give it execution permissions by running the following: chmod 0755 composer or chmod a+x composer, and put the current path to the PATH env variable in your .bashrc or .zshrc file, restart your terminal and it should work, or you can always install it globally. Bests! ;)
You don't need to add composer to your path unless you want to use it globally. You can just do
php composer.phar
Another, easy option would be to create an alias for it in your shell
eg for bash:
alias composer='php ~/phpstorm/myproject/composer.phar'
I'm following this tutorial. I need to install Laravel but I can not get pass through Composer.
Running a line like curl -sS https://getcomposer.org/installer | php is relatively easy.
I also moved it: sudo mv composer.phar /usr/local/bin/composer. I have added the PATH (export PATH="$PATH:~/.composer/vendor/bin”) by editing my .bash_profile, but no results. I can't get it to work.
Is there anyone who knows how to install composer properly?
Did you execute command?
export ~/.bash_profile
after editing this file (also reboot can be as alternative)?
Of course as quick hack you can use either php ~/.composer/vendor/bin/composer
or write hardcoded alias in ~/.bash_profile:
alias composer="~/.composer/vendor/bin/composer"
and after editing do not forget to execute export ~/.bash_profile
also check permissions if your current user can execute this file
I really appreciate all the answers above. They all helped to a final answer.
It seems that creating an alias inside the .bash_profile with the right path was solution. As of right now I can type "composer" and it will run.
The route points directly to where my composer.phar is currently installed.
A reboot was necessary as well.
alias composer="usr/local/bin/composer/composer.phar"
I am new to symfony2 and reading symblog. In third chapter while trying with data-fixtures I tried the command:
php composer.phar update
but I got the error:
Could not open input file: composer.phar
So I googled a little and tried
php composer.phar install
but still getting the same error. So please guide how to deal with this composer to install new extentions or bundles like data-fixtures in symfony2 using wamp.
If you followed instructions like these:
https://getcomposer.org/doc/00-intro.md
Which tell you to do the following:
$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer
Then it's likely that you, like me, ran those commands and didn't read the next part of the page telling you to stop referring to composer.phar by its full name and abbreviate it as an executable (that you just renamed with the mv command). So this:
$ php composer.phar update friendsofsymfony/elastica-bundle
Becomes this:
$ composer update friendsofsymfony/elastica-bundle
I had the same problem on Windows and used a different solution. I used the Composer_Setup.exe installation file supplied by the composer website and it does a global install.
After installing, make sure your PATH variable points to the directory where composer.phar is stored. This is usually C:\ProgramData\ComposerSetup\bin (ProgramData might be a hidden directory). It goes without saying, but also be sure that the PHP executable is also in your PATH variable.
You can then simply call
composer install
instead of
php composer.phar install
Background
It is helpful to know that there are two ways to install (and use) Composer: locally as a file in your project directory, or globally as a system-wide executable.
Installing Composer locally simply means that you are downloading a file (composer.phar - which is a PHP Archive) into your project directory. You will have to download it for every project that requires Composer.
Like a regular PHP file that you want to execute on the command line, you will have to run it with PHP:
php composer.phar update
Which basically tells the php executable to run the file composer.phar with update as argument.
However, if you install it globally, you can make composer itself executable, so you can call it without php (and don't have to download it for every project). In other words, you can use composer like this:
composer update
Since you are executing php composer.phar update, and you are getting the error Could not open input file: composer.phar, you probably don't have composer.phar in your current directory.
Solution
If you have Composer installed globally, simply run composer update instead of php composer.phar update.
If you don't have Composer installed yet, download the PHAR using the following command:
curl -sS https://getcomposer.org/installer | php
This will download the installer and run it using php. The installer will download the actual Composer PHAR to your current working directory, and make it executable.
To install Composer globally (I recommend this), copy the file to a location in your PATH. The exact location differs per operating system and setup, see https://getcomposer.org/doc/00-intro.md#globally for more information.
Personally, I prefer to install Composer in my home directory so I don't need sudo to install or update the composer executable (which can be a security risk). As I'm on Linux, I use the following command:
mv composer.phar ~/.local/bin/composer
If anyone else came this low on the page and still didn't find a working answer (like I did), use this:
$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer.phar
$ alias composer='/usr/local/bin/composer.phar'
$ composer --version
et voila! A working composer :-)
To solve this issue the first thing you need to do is to get the last version of composer :
curl -sS https://getcomposer.org/installer | php
I recommend you to move the composer.phar file to a global “bin” directoy, in my case (OS X) the path is:
mv composer.phar /usr/local/bin/composer.phar
than you need to create an alias file for an easy access
alias composer='/usr/local/bin/composer.phar'
If everything is ok, now it is time to verify our Composer version:
composer --version
Let's make composer great again.
I found this worked as I did not have curl installed. On Windows 8 with XAMPP installed. It will add it to your local build I use .gitignore to avoid the repo
php -r "readfile('https://getcomposer.org/installer');" | php
I got it from here: https://getcomposer.org/download/
This worked for me:
composer install
Without
php composer install
Run the following in command line:
curl -sS https://getcomposer.org/installer | php
Yesterday I was trying to install Yii2 framework on Windows 10 and I have same problem(Could not open input file: composer.phar) running this command:
php composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.9
Issue is composer.phr file is not in current directory,you need to give full path composer.phr like
php C:\ProgramData\Composer\bin\composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.9
Or you can create yii2 project using this command:
composer create-project yiisoft/yii2-app-advanced advanced 2.0.9
Or
composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.9
I had the same issue. It is solved when I made composer globally available. Now I am able to tun the commands from any where in the folder.
composer update
composer require "samplelibraryyouwant"
Use this :
php -r "readfile('https://getcomposer.org/installer');" | php
Hi friends, follow the steps to fix this issue in MAC OS
Step 1: first run the command in Terminal with your project directory
$ curl -sS https://getcomposer.org/installer | php
Step 2: Move the composer.phar in your project directory
$ mv composer.phar /Applications/MAMP/htdocs/bashrushAPI/composer.phar
Step 3: Setup alias the composer
$ alias composer='/Applications/MAMP/htdocs/bashrushAPI/composer.phar'
Step 4: Check the composer version now
$ composer --version
Composer version 1.7.2 2018-08-16 16:57:12
Step 5: Confirm the project folders and file placed on bellow
$ ls
CONTRIBUTING.md docker-compose.yml templates
README.md logs tests
composer.json phpunit.xml vendor
composer.lock public
composer.phar src
Step 6: Now update composer
$ composer.phar update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
Step 7: Run your sample project
$ php composer.phar start
php -S localhost:8080 -t public
[Thu Sep 27 03:16:11 2018] ::1:51177 [200]: /
[Thu Sep 27 03:16:11 2018] ::1:51178 [404]: /favicon.ico - No such file or directory
Easy answer, navigate to the directory where you already have the composer.json file that you want to run (ideally your project folder) then download composer into the same folder, then instantly run the install command like so:
php composer.phar install
This will automatically find the composer.json and run your required scripts. Good luck. This stuff is a breeze for terminal wizards and totally bizarre to the rest of us
I am using windows 8.0. In my case to install or update i just use composer install or something else instead of php composer.phar. This worked for me
like
composer require google/apiclient:1.*
To googlers who installed composer via HomeBrew:
make a symbolic link for /usr/local/bin/composer
ln -s /usr/local/bin/composer /usr/local/bin/composer.phar
I got this error "Could not open input file: composer.phar" while installing Yii2 using below mentioned command.
php composer.phar create-project yiisoft/yii2-app-basic basic
Solutions which worked for me was, I changed the command to
composer create-project yiisoft/yii2-app-basic basic
I hope it help!
your composer.phar should be placed in above way.
For windows, I made composer.cmd and used the below text:
php c:\programs\php\composer.phar %*
where composer.phar is installed and c:\programs\php\ is added to my path.
Not sure why this isn't done automatically.
For Windows10 Pro, Following steps fix the issue. select properties check the Unblock program option. run the installer, run the command CMD with Admin rights. At command promp run composer --version to make sure it is globally installed. you should be able to now run composer require drush/drush This is for drush dependency using composer.
Command like this :
composer.phar require intervention/image
error: composer.phar: command not found
I solved the problem by following this process
i set the composer globally and renamed composer.phar to composer then run this command composer require intervention/image . and now it's working fine
Just open cmd as Administrator and go into your project folder and check it is working or not using composer command.
The above error is because of the composer is not accessible globally.
So you need to run "cmd" as Administrator.
This is working fine for me.
If you are using Ubuntu/Linux and you are trying to run
php composer.phar require intervention/image on your command line.
Use sudo composer require intervention/image instead. This will give you want you are looking for.
I had an issue getting a package.json's script to run composer dumpautoload.
I had the file /usr/local/bin/composer.phar, and also the file ~/.bash_profile (on OSX) contained:
alias composer="php /usr/local/bin/composer.phar"
This allowed composer to work from the command line, but it didn't allow scripts to execute composer.
The fix was this:
$ cd /usr/local/bin
$ mv composer.phar composer
$ sudo chmod +x composer // +x allows the file to be executable, such as by CLI scripts
But that yielded this error Could not open input file: /usr/local/bin/composer.phar
The fix was to update ~/.bash_profile (sudo nano ~/.bash_profile), and change the composer alias to:
alias composer="php /usr/local/bin/composer"
# ie: `.phar` extension removed
Now everything is behaving as expected.
Your composer.phar must be in Source files. I had same problem and I just cut my composer.phar into mine framework-standard-edition folder, where is my whole strong textproject.
if the composer is already install all you need is to know where the composer.phar file is (its directory) after that you move to your symfony project where you have the composer.json and from that directory you execute your composer.phar file. In windows here is what you have to do.
symfony project directory_where_composer.json_is>php the_directory_where_composer.phar_is/composer update
That's all
use two steps .
curl -sS https://getcomposer.org/installer | php
sudo php composer.phar update
You can do
curl -sS https://getcomposer.org/installer | php
The -sS flag meaning don't show progress, do show errors
and then
php composer.phar install
from:
How do I get cURL to not show the progress bar?
https://packagist.org/
I've reach to this problem when trying to install composer on a Window 7 machine from http://getcomposer.org/download page. As there was an existing compose version (provided by acquia Dev Desktop tool) the installation fails and the only chance was to fix this issue manually. (or to remove Dev Desktop tool composer).
Anyway the error message is quite straightforward (Could not open input file: composer.phar), we should then tell the system where the file is located.
Edit composer.bat file and should look like:
#SET PATH=C:\Program Files (x86)\DevDesktop\php5_4;%PATH%
php.exe composer.phar %*
See that composer.phar doesn´t have a file path. When standing in a different folder than the one where composer.phar is located the system won´t be able to find it. So, just complete the composer.phar file path:
#SET PATH=C:\Program Files (x86)\DevDesktop\php5_4;;%PATH%
SET composerScript=composer.phar
php.exe "%~dp0%composerScript%" %*
Reopen your window console and that should do the trick.
EDIT: this has an issue because it always uses %~dp0%composerScript%
folder as composer execution. Then all configurations are done in that
folder (besides standing on your current project folder) and not in your project folder.
So far I haven't found a was to make a manual composer installation to
work globally on Windows. Perhaps you should go ahead with composer for windows installation mentioned above.
Do not access the composer by
composer composer.pher install
use
composer install
You can just try this command if you're already installed the Composer :
composer update
or if you want add some bundle to your composer try this :
composer require "/../"
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