What is Composer and how to install?

Hi there, I am going to explain about composer and installation.
What is a composer?
Composer is a dependency manager for PHP web applications. Composer is used in all modern PHP frameworks (Symfony, Laravel, Codeigniter, Yii and so on) and is one of the most recommended tools that solve fundamental issues in the majority of web projects.

This article will guide you through basic composer usage and advanced usage for a team environment. It will also explain what you need to change in your deployment process after integrating the composer.

The dependencies for all the PHP packages are installed automatically to reduce the workload of the developers.
composer install:
Go to https://getcomposer.org/doc/00-intro.md and download .exe file .
Once you have installed composer on your system, you can check using composer on your command prompt

1.If composer.lock does exist.
    Processes and installs dependencies from the composer.lock file.
2.If composer.lock does not exist.
    Process package installs from composer.json.
    Creates the composer.lock file based on the installed packages.

The install command reads the composer.lock file from the current directory processes it and downloads and installs all the libraries and dependencies outlined in that file. If the file does not exist it will look for composer.json and do the same.

Composer solves the following problems:
  • dependency resolution for PHP packages
  • autoloading solution for PHP packages
  • keeping all packages updated
composer update
Processes dependencies from the composer.json file (installs, updates and removes).
Creates or updates the composer.lock file according to the changes.

The update command reads the composer.json file from the current directory, processes it, and updates, removes or installs all the dependencies.

 

Comments

Post a Comment