composer – TecAdmin https://tecadmin.net How to guide for System Administrator's and Developers Mon, 26 Dec 2022 11:50:12 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 How to Install Composer on Ubuntu 22.04 https://tecadmin.net/how-to-install-composer-on-ubuntu-22-04/ https://tecadmin.net/how-to-install-composer-on-ubuntu-22-04/#respond Wed, 22 Jun 2022 17:13:44 +0000 https://tecadmin.net/?p=30277 Composer is a dependency management tool for PHP that allows you to declare the libraries your project depends on and installs them for you. In this article, we will cover the steps for installing Composer on Ubuntu 22.04. Prerequisites Shell access to a running Ubuntu system. Install PHP 5.3 or higher version. PHP’s package manager, [...]

The post How to Install Composer on Ubuntu 22.04 appeared first on TecAdmin.

]]>
Composer is a dependency management tool for PHP that allows you to declare the libraries your project depends on and installs them for you. In this article, we will cover the steps for installing Composer on Ubuntu 22.04.

Prerequisites

  • Shell access to a running Ubuntu system.
  • Install PHP 5.3 or higher version.
  • PHP’s package manager, `php-cli`, must be installed and available in your `PATH`

Installing PHP Composer on Ubuntu

The Composer’s official team provides a script to install PHP composer on Linux systems. You can download this script using the `curl` or `wget` command-line utility. Also, you can download it directly using the PHP script command line.

  1. To download the `composer-setup` script, run the following command in a terminal:
    php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" 
    
  2. Then execute the downloaded PHP script to install the composer on your Ubuntu system at the desired location. Use --install-dir to set the binary location and --filename to set the binary name. You can choose one of the below option:
    • Installing PHP composer system-wide: This will install composer in /uer/local/bin directory, that is accessible to all users:
      sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
      sudo chmod +x /usr/local/bin/composer
      
    • Installing PHP composer for specific applicaiton: Sometimes you dont’ have permission to install it globally, like shared hosting account. Then you can configure this under you application as well. To install composer locally type:
      cd /path/to/php-application && mkdir -p bin 
      php composer-setup.php --install-dir=bin --filename=composer
      chmod +x bin/composer
      

      Make sure to replace /path/to/php-application with your application directory.

  3. To see the installed composer version execute binary with -v command parameter.
    composer --version
    
    Output:
    Composer version 2.3.7 2022-06-06 16:43:28

Upgrade PHP Composer

The PHP composer has the ability to self-upgrade to the latest versions. If the composer is already installed on your system, just type the below command to upgrade the PHP composer to the latest version.

composer self-update

In my case, I already have latest version of composer. So receive the following message on terminal:

Output:
You are already using the latest available Composer version 2.3.7 (stable channel).

Working with PHP Composer

You have already installed and configured the composer on your system. The composer 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 ^3.0 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 (3.0.0) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 1 install, 0 updates, 0 removals - Downloading psr/log (3.0.0) - Installing psr/log (3.0.0): 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 article, we have covered the steps for installing Composer on Ubuntu 22.04. By using Composer, you can easily manage the dependencies of your PHP projects and ensure that all necessary libraries are installed and up to date. Whether you are new to PHP development or an experienced developer, Composer can help you streamline your workflow and improve the quality of your projects.

The post How to Install Composer on Ubuntu 22.04 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-composer-on-ubuntu-22-04/feed/ 0
How To Install and Use PHP Composer on Debian 11 https://tecadmin.net/how-to-install-and-use-php-composer-on-debian-11/ https://tecadmin.net/how-to-install-and-use-php-composer-on-debian-11/#respond Tue, 28 Sep 2021 06:22:13 +0000 https://tecadmin.net/?p=27897 PHP Composer is basically a dependency management tool for PHP applications. It provides hassle-free installation of PHP modules for the applications. The composer keeps track of all the modules required for the application and installs them with a single command. It also allows users to keep modules updated. You can easily install all the required [...]

The post How To Install and Use PHP Composer on Debian 11 appeared first on TecAdmin.

]]>
PHP Composer is basically a dependency management tool for PHP applications. It provides hassle-free installation of PHP modules for the applications. The composer keeps track of all the modules required for the application and installs them with a single command. It also allows users to keep modules updated. You can easily install all the required packages using Composer. The composer maintains a list of required packages in a JSON file called composer.json.

Composer is a similar tool to npm for Node.js, pip for Python, and bundler for ROR. Composer 2 is the latest available version for your system with enhanced performance. We will use that version to install on our system.

This tutorial helps you to install and use PHP composer on Debian 11 Bullseye Linux system.

Prerequisites

Installing PHP Composer on Debian

A PHP script is provided by the official team to configure the composer on your system. You can download it with curl or wget command-line utility. Also, you can download it with the PHP script.

Open a terminal and run:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" 

A composer-setup.php file will be created in current directory. Now execute this PHP script to install the composer at the desired location. Use --install-dir to set the binary location and --filename to set the binary name. You can install composer globally accessible for all users and projects or install locally for a specific project.

  • To install composer globally, type:
    php composer-setup.php --install-dir=/usr/local/bin --filename=composer
    chmod +x /usr/local/bin/composer
    
  • You can also install composer under the specific application. This is helpful for shared hosting environments, where you don’t have sudo or root access. To install composer locally for a specific project, type:
    cd /path/to/php-application && mkdir -p bin 
    php composer-setup.php --install-dir=bin --filename=composer
    chmod +x bin/composer
    

    Change /path/to/php-application with the actually application directory.

To see the installed composer version execute binary with -v command parameter.

composer --version
Output:
Composer version 2.2.6 2022-02-04 17:00:38

Upgrade PHP Composer

The PHP composer has the ability to self-upgrade to the latest versions. If the composer is already installed on your system, just type the below command to upgrade PHP composer to the latest version.

composer self-update

In my case, I already have latest version of composer. So receive the following message on terminal:

Output:
You are already using the latest available Composer version 2.2.6 (stable channel).

Working with PHP Composer

You have already installed and configured the composer on your system. Composer 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 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.

The post How To Install and Use PHP Composer on Debian 11 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-and-use-php-composer-on-debian-11/feed/ 0
How to Remove Package from Laravel (Composer) https://tecadmin.net/composer-remove-laravel-package/ https://tecadmin.net/composer-remove-laravel-package/#respond Wed, 19 May 2021 08:42:51 +0000 https://tecadmin.net/?p=25386 Composer is the most popular way for managing packages in PHP bases applications. Laravel also relies over composer for installing, upgrading and removing packages. Composer 2.0 is the latest version available for installation. This is more powerful, fast and fully compatible with older versions. Remove Package from Laravel You can remove all packages no longer [...]

The post How to Remove Package from Laravel (Composer) appeared first on TecAdmin.

]]>
Composer is the most popular way for managing packages in PHP bases applications. Laravel also relies over composer for installing, upgrading and removing packages. Composer 2.0 is the latest version available for installation. This is more powerful, fast and fully compatible with older versions.

Remove Package from Laravel

You can remove all packages no longer required from the Laravel application. Use the following command to remove the package from vendor. This will also update composer.json and composer.lock accordingly.

composer remove vendor/package 

Change vendor/package with the packages name to delete.

For example, below command will delete doctrine/annotations from Laravel application.

composer remove doctrine/annotations 

That’s it. You may now need to remove all the references added in the application code. The above instructions can be used with any PHP application using composer for removing packages.

The post How to Remove Package from Laravel (Composer) appeared first on TecAdmin.

]]>
https://tecadmin.net/composer-remove-laravel-package/feed/ 0
How To Install PHP Composer on Fedora 36/35/34 https://tecadmin.net/install-composer-fedora/ https://tecadmin.net/install-composer-fedora/#respond Thu, 09 Apr 2020 11:51:08 +0000 https://tecadmin.net/?p=21070 Composer is a dependency management tool for PHP similar to npm for nodejs and bundle for ruby. Using the composer tool we can define the required libraries for our project and install them with the composer in a single command. We don’t need to search for each library individually to install each time. This tutorial [...]

The post How To Install PHP Composer on Fedora 36/35/34 appeared first on TecAdmin.

]]>
Composer is a dependency management tool for PHP similar to npm for nodejs and bundle for ruby. Using the composer tool we can define the required libraries for our project and install them with the composer in a single command. We don’t need to search for each library individually to install each time.

This tutorial will help you to install PHP Composer on Fedora 34/33/32/31/30 Linux. We are assuming that you already have installed PHP on your system.

Prerequisites

  • Sudo privileged account with shell access.
  • You must have PHP installed on your system.

Install Composer on Fedora

PHP Composer is available as a binary file to directly download and use. Open the terminal and download the composer binary file using the curl command-line tool.

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

Now use the following commands to make composer available globally for all users in your system, which can be used for all PHP applications on that system.

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

To find the version of the composer simply use the following command. This will also show you the uses of the composer on the command line.

composer -V  

Yo will see the output like below:

   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 2.1.14 2021-11-30 10:51:43

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

Update Composer

If there is an upgrade available, Composer displays the information with every run. Composer is built with the ability to upgrade itself. You just need to run the following command to update composer.phar to the latest version.

composer self-update

The post How To Install PHP Composer on Fedora 36/35/34 appeared first on TecAdmin.

]]>
https://tecadmin.net/install-composer-fedora/feed/ 0
How to Install Composer on MacOS https://tecadmin.net/install-composer-on-macos/ https://tecadmin.net/install-composer-on-macos/#comments Fri, 06 Sep 2019 15:17:56 +0000 https://tecadmin.net/?p=19269 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 [...]

The post How to Install Composer on MacOS appeared first on TecAdmin.

]]>
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

2. Install Composer on macOS

Download the composer binary file from the getcomposer.org website by running the following command. It will create a file named composer.phar 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.

mkdir -p /usr/local/bin 
mv composer.phar /usr/local/bin/composer 
chmod +x /usr/local/bin/composer 

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

composer 


   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 2.3.5 2022-04-13 16:43:00

Usage:
  command [options] [arguments]

Options:
  -h, --help                     Display help for the given command. When no command is given display help for the list command
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
      --ansi|--no-ansi           Force (or disable --no-ansi) ANSI output
  -n, --no-interaction           Do not ask any interactive question
      --profile                  Display timing and memory usage information
      --no-plugins               Whether to disable plugins.
      --no-scripts               Skips the execution of all scripts defined in composer.json file.
  -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.
      --no-cache                 Prevent use of the cache
  -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

3. Upgrade PHP Composer

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

sudo composer self-update 

4. Uninstall (Remove) PHP Composer

As the composer is configured with a single file, you can simply remove it from your system.

sudo rm /usr/local/bin/composer 

Conclusion

This tutorial helped you to install the PHP composer on the macOS system. That will help you to manage the dependencies of a PHP-based application.

The post How to Install Composer on MacOS appeared first on TecAdmin.

]]>
https://tecadmin.net/install-composer-on-macos/feed/ 8
How To Install and Use PHP Composer on Debian 10/9 https://tecadmin.net/install-php-composer-debian/ https://tecadmin.net/install-php-composer-debian/#comments Sun, 01 Apr 2018 07:12:27 +0000 https://tecadmin.net/?p=15723 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 [...]

The post How To Install and Use PHP Composer on Debian 10/9 appeared first on TecAdmin.

]]>
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.

The post How To Install and Use PHP Composer on Debian 10/9 appeared first on TecAdmin.

]]>
https://tecadmin.net/install-php-composer-debian/feed/ 5
How to Install PHP Composer on CentOS/RHEL 8/7 https://tecadmin.net/install-php-composer-on-centos/ https://tecadmin.net/install-php-composer-on-centos/#comments Wed, 18 Nov 2015 07:42:51 +0000 https://tecadmin.net/?p=9152 Composer is a dependency management tool for PHP similar to npm for nodejs and bundle for ruby. Using the composer tool we can define required libraries for our project and install it with the composer in a single command. We don’t need to search for each library individually to install each time. This tutorial will [...]

The post How to Install PHP Composer on CentOS/RHEL 8/7 appeared first on TecAdmin.

]]>
Composer is a dependency management tool for PHP similar to npm for nodejs and bundle for ruby. Using the composer tool we can define required libraries for our project and install it with the composer in a single command. We don’t need to search for each library individually to install each time.

This tutorial will help you to install PHP Composer on CentOS, RHEL & Fedora operating systems. We are assuming that you already have installed PHP on your system.

Prerequsitis

  • Sudo privileged account with shell access.
  • You must have PHP installed on your system.

Install Composer on CentOS

To install php composer on Redhat based systems. We just need to download composer executable and put under bin directory.

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

Now use the following commands to make composer available globally for all users in your system, which can be used for all PHP applications on that system.

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

To find the version of composer simply use the following command.

composer -V

Composer version 1.10.5 2020-04-10 11:44:22

Update Composer

If there is any upgrade available, Composer displays the information with every run. Composer is build with the ability to upgrade itself. You just need to run following command to update composer.phar to the latest version.

composer self-update

The post How to Install PHP Composer on CentOS/RHEL 8/7 appeared first on TecAdmin.

]]>
https://tecadmin.net/install-php-composer-on-centos/feed/ 1
How To Install PHP Composer on Ubuntu 18.04 & 16.04 https://tecadmin.net/install-php-composer-on-ubuntu/ https://tecadmin.net/install-php-composer-on-ubuntu/#comments Sat, 25 Jul 2015 16:56:08 +0000 https://tecadmin.net/?p=6254 The PHP Composer is a package management tool for PHP similar to NPM for Nodejs and bundle for Ruby. Using the composer tool we can define required libraries for our project and install it with the composer in the single command. We don’t need to search for each library to install. This tutorial helps you [...]

The post How To Install PHP Composer on Ubuntu 18.04 & 16.04 appeared first on TecAdmin.

]]>
The PHP Composer is a package management tool for PHP similar to NPM for Nodejs and bundle for Ruby. Using the composer tool we can define required libraries for our project and install it with the composer in the single command. We don’t need to search for each library to install.

This tutorial helps you to install and configure PHP composer on Ubuntu 19.10, Ubuntu 18.04 LTS, and Ubuntu 16.04 LTS systems.

1. Prerequisites

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

2. Install Composer on Ubuntu

To install PHP composer on an Ubuntu system. We just need to download the composer executable and put it under bin directory.

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

Now use the following commands to make composer available globally for all users in your system, which can be used for all PHP applications on that system.

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

After installation of the composer on your system. Type composer at the command prompt. This will provide you with composer version details along with options available with the composer command.

composer 

Output:

  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 2.1.14 2021-11-30 10:51:43

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 Composer

You can download the latest version of the composer by executing the same commands used for installation. The composer also has the capabilities to update itself. Use the following command to update the composer itself.

sudo composer self-update 

Conclusion

This tutorial described you to install PHP Composer on Ubuntu systems. Also provides commands to upgrade composer with a single command.

The post How To Install PHP Composer on Ubuntu 18.04 & 16.04 appeared first on TecAdmin.

]]>
https://tecadmin.net/install-php-composer-on-ubuntu/feed/ 10