Saturday, December 2, 2023
HomePHPHow To put in PHP Composer in Linux/Home windows

How To put in PHP Composer in Linux/Home windows


This tutorial helps to set up Composer into your system. The PHP Composer is a robust dependency supervisor for PHP tasks. It helps to including, managing, and updating libraries and packages in your undertaking.

You should use Composer as a dependency supervisor for net functions, a content material administration system, or any PHP-based undertaking, It helps to automate the administration of your undertaking’s dependencies.

You can even learn: Find out how to Uninstall Composer in Home windows 10/11

Find out how to Set up PHP Composer

Let’s stroll you thru the step-by-step course of of putting in PHP Composer in your system.

Step 1: Conditions

There are the next stipulations in place to set up Composer:

You must requires PHP to be put in in your system. You may verify if PHP is put in by opening a terminal or command immediate and run the under command:

php -v

If PHP shouldn’t be put in, you’ll want to put in it. You may obtain PHP from the official PHP web site https://www.php.web/downloads.php.

  • Linux: You may set up PHP utilizing a package deal supervisor like apt.
  • macOS: You may set up PHP utilizing the Brew package deal supervisor.
  • Home windows: You may set up PHP utilizing XAMPP or WAMP.

Step 2: Confirm the Installer

The Composer is distributed as a PHP script, and you may obtain it utilizing the next command:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

The above command will obtain the Composer installer script (composer-setup.php) to your present listing.

Step 3: Confirm the Installer

You may confirm its SHA-384 hash with the anticipated hash from the Composer web site https://composer.github.io/pubkeys.html

php -r "if (hash_file('sha384', 'composer-setup.php') === 'EXPECTED_HASH_HERE') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

Change ‘EXPECTED_HASH_HERE‘ with the hash you obtained from the Composer web site. The above command will evaluate with the precise hash of the downloaded installer script.

Step 4: Run the composer Installer

We have now already put in composer and navigated to that location and run the under command:

php composer-setup.php

The above command will set up Composer globally in your system and make it obtainable system-wide.

Composer Globally Accessible on Linux

You may make Composer globally accessible from the command line in Linux or macOS. You must transfer the Composer executable to a listing in your system’s PATH. You should use the next command:

sudo mv composer.phar /usr/native/bin/composer

Composer globally accessible in Home windows

You must set composer.phar file path in your system’s PATH, resembling C:WindowsSystem32.

Confirm the Set up

To confirm that Composer has been efficiently put in, open a brand new terminal or command immediate window and run the next command:

composer --version

How To Replace Composer in Linux

You may replace the composer utilizing the under command:

composer self-update

The above command will fetch the most recent model of Composer and replace it in your system.

Conclusion

We’ve walked you thru the step-by-step set up of PHP Composer in your system. The Composer is a robust device that can enable you handle dependencies in your PHP tasks. You may handle PHP undertaking package deal dependencies and seamlessly switch tasks between completely different techniques with out considerations about package deal variations.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments