DEV Community

Cover image for My recommended way to install composer on linux ubuntu if you use xammp
Chidiebere Chukwudi
Chidiebere Chukwudi

Posted on • Updated on • Originally published at linkedin.com

 

My recommended way to install composer on linux ubuntu if you use xammp

Hi, the following technique you are about to employ will save you time having to install *php-cli * via apt-get and php extensions on your linux when xammp already comes with php as a bundle.

Requirement:

  1. You already installed xammp
  2. Make sure you have followed step one...lol

Installing Composer

To install composer run the command below

sudo curl -s https://getcomposer.org/installer | /opt/lampp/bin/php
Enter fullscreen mode Exit fullscreen mode

After installation, we'll have to symlink php bundle that comes along with xampp after which we run the command below to allow 'composer' command to run globally (this will run from within the folder where you've just installed composer in which a composer.phar file has just been created):

sudo ln -s /opt/lampp/bin/php /usr/local/bin/php
Enter fullscreen mode Exit fullscreen mode

Next, we'll run the below command to allow composer to reflect globally in the system

sudo mv composer.phar /usr/local/bin/composer
Enter fullscreen mode Exit fullscreen mode

Bonus

If you already installed composer via apt-get but wish to use the xammp php bundle (since composer must require php-cli), you can do that by adding XAMPP php to environment variables.

Run the following command:

export PATH=$PATH:/opt/lampp/bin
Enter fullscreen mode Exit fullscreen mode

Yep....That's all! Let me know your thoughts!

Reference

Top comments (2)

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
jovialcore profile image
Chidiebere Chukwudi

Yea. I understand but there are people who still use the kind of setup in the post

Why You Need to Study Javascript Fundamentals

The harsh reality for JS Developers: If you don't study the fundamentals, you'll be just another β€œCoder”. Top learnings on how to get to the mid/senior level faster as a JavaScript developer by Dragos Nedelcu.