Install Composer and configure with XAMPP
Solution 1
Install composer like so:
sudo curl -s https://getcomposer.org/installer | /opt/lampp/bin/php
After installation, you should then symlink it by running command:
sudo ln -s /opt/lampp/bin/php /usr/local/bin/php
Then run the command below to allow the 'composer' command to be run globally (this will be run from within the folder where you've just installed composer in which a composer.phar file has just been created):
sudo mv composer.phar /usr/local/bin/composer
Solution 2
Enable the php version from xampp globally
In Terminal run:
sudo gedit /etc/environment
Add this inside quote
":/opt/lampp/bin"
click save then close everything.
or
symlink - "ln -s /opt/lampp/bin/php /usr/local/bin/php"
Install Curl
sudo apt-get install curl
Install composer
sudo curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
now:: try "composer
" - it should work!
Solution 3
I found out the solution. XAMPP has php-cli already installed so there is no need to install php-cli via apt-get.
The reason for the above problem is, as PHP is installed as a bundle along with XAMPP, the OS doesn't know it is there. So for this we should add the XAMPP php to environment variables. This done by typing following command in terminal
export PATH=$PATH:/opt/lampp/bin
Now, I can use my global setup of Composer effortlessly!
Related videos on Youtube
Rohan Sanap
Updated on September 18, 2022Comments
-
Rohan Sanap over 1 year
After reading on web, I learned that XAMPP has php-cli pre-installed and it is accessed by
/opt/lampp/bin/php
. I installed composer using the following and all went well:sudo curl -s https://getcomposer.org/installer | /opt/lampp/bin/php
Composer was installed perfectly. After that, I did this to make it global:
sudo mv composer.phar /usr/local/bin/composer
Now I made a folder called "fb" and made following composer.json file :
{"require":{ "facebook/php-sdk-v4":"4.0.*" }}
Now when I type
$ composer install
in terminal, following message is displayed:rohan@sanap:~/Desktop/fb$ composer install /usr/bin/env: php: No such file or directory
Please help me to use composer. What should I do in following situation?
-
Murtuza Zabuawala almost 6 yearsthis answer is more perfect in my case
-
Naveen Kumar V almost 6 yearsalso "mv composer.phar /usr/local/bin/composer" worked for me.
-
Naveen Kumar V almost 6 yearsWorked for me :)
-
kinsley kajiva almost 5 years@NaveenKumarV thanks for the comment that was the final touch that was need for mine to work !.
-
Raymond Wachaga almost 5 years@NaveenKumarV Your comment should be added to the solution. Running composer without doing this final step doesn't work.