ホーム > Laravel > How to set up the environment to use composer command
Laravel

How to set up the environment to use composer command

Thank you for your continued support.
This article contains advertisements that help fund our operations.

I summarized how to install composer in order to use the composer command.

⇨ What is Laravel?

⇨ Table of Contents for Laravel Articles

Environment

MacOS

Easiest installation method

It's super easy to install on Mac.

brew install composer

That's it.

To confirm the installation, run the command:

composer

If you see the following output:

Composer confirmation image

then you're all set.

If this doesn't work, please refer to the following:

Steps as written on the official website

For other environments, follow the official download instructions.

Assuming PHP is installed on your computer.

Open the official page

https://getcomposer.org/download/

What you need to do

  1. Download Composer to a directory
  2. Move the downloaded Composer to /usr/local/bin

By performing these two steps, you can use it.

Create a directory on Desktop and perform these two tasks there.

Create a working directory.

On Mac, running the following command will create a working directory:

cd ~/Desktop
mkdir test-dir
cd test-dir

Download Composer

Visit https://getcomposer.org/download/

Copy and paste the top 4 lines of the PHP command.

(The command to copy may have changed, so check the link and copy it.)

Then, paste and execute the 4 lines in the terminal.

If it works, a composer.phar file will be created in the current directory.

Move composer.phar to /usr/local/bin to finish

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

That's it.

Run the command:

composer

If you see:

Composer confirmation image

then everything is set.

Conclusion

Did it work out for you?

Usually, installing with brew completes instantly, but sometimes you may need to use the method below, especially when setting up environments on EC2, so please feel free to use it.

That's all.

Please Provide Feedback
We would appreciate your feedback on this article. Feel free to leave a comment on any relevant YouTube video or reach out through the contact form. Thank you!