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 and Use PHP Composer on Debian 10/9

    How To Install and Use PHP Composer on Debian 10/9

    RahulBy RahulApril 1, 20183 Mins ReadUpdated:September 28, 2021

    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 Debian 10 Buster, Debian 9 Stretch, and Debian 8 Jessie systems.

    1. Prerequsities

    • Shell access to a running Debian system with sudo privilege.
    • PHP must be installed and configured, version 5.3 or higher.

    2. Install Composer on Debian

    You can download the composer script from the 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

    Copy 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 the composer for easy use.

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

    Type composer at the command prompt. This will provide you composer version details along with options available with the composer command.

    composer 
    
    Output:
    ______ / ____/___ ____ ___ ____ ____ ________ _____ / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/ / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ /_/ Composer version 2.1.8 2021-09-15 13:55:14 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

    3. Upgrade PHP Composer

    The composer has the ability to upgrade itself without downloading again. Simply run the below command from the terminal to upgrade compose on Debian.

    sudo composer self-update 
    

    Working with PHP Composer

    Assuming you have been successfully configured PHP composer on your system. That will help you to manage modules for your application. For example, to install a new module for your application.

    Switch to the PHP application.

    cd /path/to/php-application 
    

    Run the following command to install psr/log module in the application.

    composer require psr/log
    
    Output:
    Using version ^1.1 for psr/log ./composer.json has been created Running composer update psr/log Loading composer repositories with package information Updating dependencies Lock file operations: 1 install, 0 updates, 0 removals - Locking psr/log (1.1.4) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 1 install, 0 updates, 0 removals - Downloading psr/log (1.1.4) - Installing psr/log (1.1.4): Extracting archive Generating autoload files

    Composer will automatically create or update composer.json file at application root directory. Now, the application can use the functionality provided by the module.

    The above command will install the latest version of the module. You can also define the module version you want to install for your application. If the module is already installed, it will automatically downgrade/upgrade the
    package to the specified version.

    composer require psr/log=1.0
    

    The module no longer required can be removed with the following command.

    composer remove psr/log
    

    All the above commands also update composer.json file accordingly.

    Conclusion

    In this tutorial, you have found instructions to install composer on a Debian Linux system. You can install composer globally to allow access to all users and applications. Also, you can install composer for a specific directory.

    composer PHP
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow To Install LAMP (Apache, MySQL, PHP) on Debian 9 Stretch
    Next Article How to Compile and Run C/C++ Programs in Linux

    Related Posts

    How to Install Composer on Ubuntu 22.04

    Updated:June 24, 20223 Mins Read

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

    Updated:June 19, 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 Apache, MySQL, PHP (LAMP Stack) on Ubuntu 22.04

    Updated:June 28, 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

    5 Comments

    1. Amy on September 25, 2019 10:53 am

      Thank You. Very helpful

      Reply
    2. Juan on August 22, 2019 12:46 pm

      Gracias, me sirvio bastante

      Reply
    3. No Name on October 21, 2018 10:57 pm

      Thank you.

      Reply
    4. ipanera on July 27, 2018 10:00 am

      Great!!
      Thanks a lot

      Reply
    5. anonymous on June 5, 2018 9:32 pm

      thanks.

      Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • How To Install Docker on Ubuntu 22.04
    • How to Install Bower on Ubuntu 22.04 & 20.04
    • How to run “npm start” through Docker
    • Filesystem Hierarchy Structure (FHS) in Linux
    • How to accept user input in Python
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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