How to install Composer on a Mac?

Stefan Izdrail

Founder & Senior Architect · 2026-06-29

Laravel Company
Title: Mastering Composer Installation on Your Mac for Smooth Laravel Development Introduction: Composer is an essential tool in the world of PHP development, widely used to manage dependencies and package management for both Laravel and other frameworks. In this comprehensive guide, we'll walk you through installing Composer on your Mac, addressing common issues you might encounter during setup. By the end of it, you should be ready to leverage Composer for your Laravel projects easily. Body: 1. Prerequisites: - Ensure that you have an updated version of macOS and Xcode Command Line Tools installed on your system. To verify this, open Terminal and execute the following command: `xcode-select --install` If there is a warning saying "xcode-select: error: command line tools are already installed. Please use 'Software Update' to install any available updates.", it means you have the latest tools installed. In case of an error message, follow the on-screen instructions to install Command Line Tools first. [link to https://laravelcompany.com/blog/install-homebrew]: (Optional) If you use Homebrew package manager, this can make managing and setting up your development environment much easier. Install Homebrew if needed with the command: `ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"` 2. Installing Composer - Open Terminal and navigate to your preferred working directory (e.g., cd ~/Projects). Download the composer installer: `curl -sS https://getcomposer.org/installer | php` (As per the user's initial issue, this command might result in errors if you don't have PHP installed or its path isn't set correctly. We will address this shortly.) 3. Addressing PHP Installation and Path Issues: - To install PHP on your Mac, use Homebrew (if not already done). Run the following command: `brew install php` - Set up the path environment variable for PHP: `export PATH="$HOME/.config/homebrew/Cellar/php/7.4.0_1/bin:$PATH"` (Replace the version with the one you have installed) 4. Installing Composer Successfully - Now, try executing the command again from step 2: `curl -sS https://getcomposer.org/installer | php` - If successful, a message like "Created project skeleton file 'composer.json' in '/Users//Projects'" should appear. This indicates that Composer has been installed successfully. 5. Updating Composer: - To ensure you always have the latest version of Composer, run this command: `php composer self-update` It will download and install a new update if available. Conclusion: By following the steps above, you should now be able to install Composer on your Mac without facing any issues related to PHP installation or path errors. If you encounter any problems during this process, make sure to double-check the prerequisites or seek help from our expert team at https://laravelcompany.com. Happy Laravel development!