composer guide

How to use composer PHP

Sometimes you need to use composer to install lib depend or module was written by PHP in the post I show you how to set up the composer and use it on your server.

If you some control panel as Cpanel or Plesk Panel the composer is installed so just rum command

composer --version

If the command shows the current version composer installed in your server. That composer already installed else go to step install composer

1. Install composer to your server

Step 1. Download composer

The first download composer with the command:
curl -sS | php

The command above will download a file composer.phar to the current directory
If you can run use composer with command

php composer.phar require magepow/core
or php -dmemory_limit=4G composer.phar require magepow/core

php composer.phar require magepow/core –no-update
php -dmemory_limit=4G composer.phar update

If you don’t want inlcude php in command you can set permssion execute for file composer.phar with command:
chmod +x composer.phar
Continue you can run command without php

composer.phar require magepow/core

If you want run command without .phar you follow next step

Setup 2 environment run command composer

Run command below to make command composer without .phar. This require root permission on your server.

cp composer.phar /usr/local/bin/composer && cp composer.phar /usr/local/bin/composer.phar && cp composer.phar /usr/bin/composer && mv composer.phar /usr/bin/composer.phar

Now you can run command check version composer –verion
Try install a module example: composer require magepow/core

2. Upgrade or Downgrade composer version

Update version composer from 1.x

You can use one command below

composer self-update
composer self-update --1

Upgrade version composer from 1.x to 2.x

composer self-update --2

Downgrade 2.x to 1.x

composer self-update –1