Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Programming»PHP»How to Install Composer on MacOS

    How to Install Composer on MacOS

    RahulBy RahulSeptember 6, 20192 Mins ReadUpdated:December 11, 2020

    The PHP Composer is a package management tool. It removes the hassle of maintaining PHP packages for an application manually. You can easily install all the required packages using Composer. It maintains a list of required packages in a JSON file called composer.json. This tutorial helps you to install and configure PHP composer on macOS operating system.

    install composer on macos

    1. Prerequisites

    • Shell access to a running macOS
    • PHP 5.3 or higher version must be installed

    2. Install Composer on macOS

    Download composer binary file from getcomposer.org website by running the following command. It will create a composer.phar file in the current directory.

    curl -sS https://getcomposer.org/installer | php
    

    Now, copy this composer.phar file under bin directory to make available anywhere in the system. Also, set the execute permission on file. I have changed the filename from composer.phar to composer for the easy use.

    mv composer.phar /usr/local/bin/composer
    chmod +x /usr/local/bin/composer
    

    Run composer command on the command prompt. This will provide you composer version details along with options available with composer command.

    composer 
    
       ______
      / ____/___  ____ ___  ____  ____  ________  _____
     / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
    / /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
    \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                        /_/
    Composer version 2.0.8 2020-12-03 17:20:38
    
    Usage:
      command [options] [arguments]
    
    Options:
      -h, --help                     Display this help message
      -q, --quiet                    Do not output any message
      -V, --version                  Display this application version
          --ansi                     Force ANSI output
          --no-ansi                  Disable ANSI output
      -n, --no-interaction           Do not ask any interactive question
          --profile                  Display timing and memory usage information
          --no-plugins               Whether to disable plugins.
      -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.
          --no-cache                 Prevent use of the cache
    

    3. Upgrade PHP Composer

    The PHP composer provides a command-line option (self-update) to upgrade itself. You can simply run below command from the terminal to upgrade compose on your macOS.

    sudo composer self-update
    

    Conclusion

    This tutorial described you to install composer on macOS system.

    composer PHP
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Prevent Image Hotlinking in Apache with .htaccess
    Next Article How to Install Windows Service via Command Line

    Related Posts

    How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04

    Updated:May 9, 20223 Mins Read

    How To Install Linux, Nginx, MySQL, & PHP (LEMP Stack) on Ubuntu 22.04

    Updated:April 7, 20227 Mins Read

    How To Install LAMP Stack on Ubuntu 22.04 LTS

    Updated:April 20, 20225 Mins Read

    How To Setup Apache, PHP & MongoDB in Ubuntu & Debian

    Updated:October 8, 20213 Mins Read

    How To Install and Use PHP Composer on Debian 11

    Updated:February 16, 20224 Mins Read

    How To Install PHP (8.1, 7.4 & 5.6) on Debian 11

    Updated:February 16, 20224 Mins Read

    7 Comments

    1. anon on December 9, 2021 7:16 pm

      thx

      Reply
    2. Max on January 28, 2021 12:47 pm

      Rahul, your name describes your way of updating composer. “Do not run Composer as root/super user! See https://getcomposer.org/root for details”

      Reply
    3. Anders Hellman on December 3, 2020 2:34 pm

      You also have to create the bin directory first. Like so:
      sudo mkdir /usr/local/bin
      Then
      sudo mv composer.phar /usr/local/bin/composer
      chmod +x /usr/local/bin/composer

      Reply
    4. Andrea on November 24, 2020 1:13 am

      You might have to create the /bin directory (If on Catalina)

      Reply
    5. Ayorinde Adunse on November 1, 2020 9:57 am

      Run using homebrew. Run the command brew install composer

      Reply
    6. MustafaH on January 6, 2020 2:34 am

      Thank you for information but I have a problem when installing composer.

      I’m using MacOS Catalina and when I try to use composer globally I can’t. I can’t move the phar file.

      Any suggestion?

      Thank you

      Reply
      • LEO on August 7, 2020 7:25 am

        You should use sudo mv composer.phar /usr/local/bin/composer

        Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Enable / disable Firewall in Windows
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.