Readytocode
  • Home
  • Laravel
  • PHP
  • React Js
  • Git
  • Server
Facebook X (Twitter) Instagram
Readytocode
  • Home
  • Laravel
  • PHP
  • React Js
  • Git
  • Server
Facebook X (Twitter) Instagram Pinterest LinkedIn Reddit
Readytocode
You are at:Home What is composer?

PHP

What is composer?

JustinBy JustinFebruary 1, 2022Updated:February 2, 2022No Comments2 Mins Read
Facebook Twitter Pinterest LinkedIn Tumblr Email




Composer is a cross-platform dependency manager for PHP.  It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. Composer allows developers to specify project dependencies in a composer.json file and then Composer automatically handles the rest.

Installation

Depending on the operating system you are using it can be installed differently. In this post i will address following operating systems:

  • Mac OS
  • Window OS
  • Linux OS

Install composer on Mac

Open your mac terminal window and run following commands:

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

now we move composer.phar file to a executable directory

$ sudo mv composer.phar /usr/local/bin/

open bash_profile file using nano editor

$ nano ~/.bash_profile

add this line below to bash_profile and save using CMD + x + Enter

alias composer="php /usr/local/bin/composer.phar"

once file is saved we need to run following command to activate our changes

$ source ~/.bash_profile

Now, composer installed on mac os and you can verify using

$ composer --V

 

Install composer on linux or ubuntu

Open linux terminal window and run following commands

$ sudo apt-get update

make sure you have curl installed first , if you do not have curl installed run below command to install curl on your linux operating system

$ sudo apt-get install curl

Now install composer

$ curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

verify the composer installation

$ composer -V

 

Install composer on Windows

Download and run Composer-Setup.Exe. It will install the latest Composer version and set up your PATH so that you can call composer from any directory in your command line.

How does composer work?

Once you install composer on your machine. You can use the below steps

  • create a composer.json file
  • open terminal window and head towards your project root folder
  • run composer install command
  • this will generate vendor folder with all your project dependencies
  • include following line in your php script
  • require_once ‘vendor/autoload.php’
  • now, your dependencies will be auto-loaded. You do not need to include them manually.

How to install/update a composer dependency?

$ composer require facebook/php-sdk

 

Total
0
Shares
Share 0
Tweet 0
Pin it 0
Share 0

Like this:

Like Loading...

Related

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
Justin
  • Website

Related Posts

How to install Steam on Ubuntu 22.04 step by step

April 20, 2023

What is, How to Install & Use Kali Linux

April 1, 2023

ufw status inactive on Ubuntu 22.04

March 30, 2023

Leave A Reply Cancel Reply

Featured Posts
  • Why meta tag is important for seo 1
    How to change react Page title, Page Description and some other meta Tag
    • August 4, 2023
  • 2
    How to Generate image from text with Laravel 10
    • May 16, 2023
  • Laravel 10 Restrict User Access 3
    Laravel 10 Restrict User Access
    • May 3, 2023
  • Laravel 10 Pagination Example 4
    Laravel 10 Pagination Example
    • May 3, 2023
  • install Steam on Ubuntu 5
    How to install Steam on Ubuntu 22.04 step by step
    • April 20, 2023



Readytocode
Facebook X (Twitter) Instagram Pinterest
  • About Us
  • Privacy Policy
© 2025 ReadyToCode.

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

%d