Yogesh Chauhan's Blog

How to Install PHP composer in Mac OS Catalina?

in PHP on December 1, 2020

Step 1

Download and Install the Composer.

Copy the following code and run in your terminal.


php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

Get the latest version from the official website.

This installer script will simply check some php.ini settings, warn you if they are set incorrectly, and then download the latest composer.phar in the current directory.

The 4 lines above will, in order:

1. Download the installer to the current directory

2. Verify the installer SHA-384

3. Run the installer

4. Remove the installer

Step 2

Place the Composer PHAR globally accessible directory.

You can place the Composer PHAR anywhere you wish.

If you put it in a directory that is part of your PATH, you can access it globally.

On Unix systems (Linux/Mac) you can even make it executable and invoke it without directly using the php interpreter.

Run this command to move composer.phar to a directory that is in your path:


mv composer.phar /usr/local/bin/composer

Step 3

Make sure it is globally accessible.

Run this command and check:


composer

It will show you details about the composer.


Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Aug 15 Is PHP still good for back-end programming? #Aug 10 How to create a multisite network in WordPress? #Aug 3 How to create a circle that follows a cursor using JavaScript and CSS? #Aug 3 How to make a curtain slider using jQuery and CSS? #Aug 2 How to progressively load images and add a blurry placeholder? #Aug 1 How to create a placeholder loader (throbber) using CSS?
You might also like these
The Differences Between HAVING Clause and WHERE Clause in SQLSQL/MySQLSQL Left JoinSQL/MySQLNew to  Drupal? Here’s What You Need to KnowDrupalCheck if mixin is being called in a style rule or not in SCSSSCSSEffects in ReactReact4 different ways to create JavaScript ObjectsJavaScript