How to Install and Use Composer on Ubuntu 16.04

Prerequisites

Procedure

Logging on to Your Console

Installing the Dependencies

# sudo apt-get update# sudo apt-get upgrade
sudo apt-get install curl php-cli php-mbstring git unzip

Installing PHP

Installing Composer

cd ~curl –sS https://getcomposer.org/installer -o composer-setup.php
php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
Output Installer verified
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
OutputAll settings correct for using ComposerDownloading 1.1.1...Composer successfully installed to: /usr/local/bin/composerUse it: php /usr/local/bin/composer
Output ______ / ____/___  ____ ___  ____  ____  ________  _____ / /  / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___// /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ /_/Composer version 1.1.1 2016-05-17 12:25:44Usage: 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.. . .

Generating the Composer.json File

cd ~ mkdir slugify cd slugify

Finding the Package from the Package List

Adding the Package

$ composer require cocur/slugify
Output Using version ^2.1 for cocur/slugify ./composer.json has been created Loading composer repositories with package information Updating dependencies (including require-dev) - Installing cocur/slugify (v2.1.1) Downloading: 100%  Writing lock file Generating autoload files
$ ls -l
Output total 12 -rw-rw-r-- 1 gqadir gqadir  59 Jan 17 10:24 composer.json -rw-rw-r-- 1 gqadir gqadir 2894 Jan 17 10:24 composer.lock drwxrwxr-x 4 gqadir gqadir 4096 Jan 17 10:24 vendor

Updating the Project Dependencies

composer update vendor/package vendor2/package2

Summary

Original Source

--

--

--

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Understanding Docker’s Architecture

Deep Dive into Alibaba Cloud F3 FPGA as a Service Instances

What’s New with Mars — Alibaba’s Distributed Scientific Computing Engine

Integrate Alibaba Cloud Log Service into Istio ruuning on Alibaba Cloud Container Service for…

Maker Fest 2018

CS373 Spring 2022: Luca Santos

Object Storage — How Is It Built? (3/3)

Solving second order ODEs Using MATLAB

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

More from Medium

Implementing RDS IAM authentication in a PHP/MySQL application

Setup a LEMP Stack on Ubuntu 22.04

How view branches sorted by date in specific format and order - Git tricks(2)

BEGINNERS GUIDE TO LARAVEL 9 LUMEN : HOW TO CREATE RESTful APIs WITH LUMEN 9