NPM, Bower and Composer, which one to use?

10

Can anyone explain the difference between NPM, Bower and Composer.

They are all package managers, correct?

But when should each be used?

    
asked by anonymous 05.01.2017 / 20:09

4 answers

17

Yes that's right, they're all package managers. But the type of packages they handle is different.

I can already begin by explaining that composer is a package manager focused on php (there are exceptions, for example you can also "install" jQuery but by convention and by habit people tend to choose bower for this specific effect), if you internalize what composer is for php (although there are exceptions) you will not make confusion. While others are not for php packages.

While others may be confused, yes, but I will try to make them cease to be.

Npm is mainly for managing packages / modules of node.js, it has some exceptions but usually these have the possibility to choose which to use, eg: link .

Bower is used to manage front-end packages such as html, css (ex, bootstrap etc.), javascript (eg Jquery etc.), everything to do with layout , browser, not the server), often even entire templates can be downloaded with bower, ex link .

    
05.01.2017 / 20:26
10
  • composer is for PHP packages (although you can install more than PHP, you can even install things like bootstrap and jQuery) and it installs packages available at link

      

    Creating and publishing a package link

  • npm to node.js and install packages available at link

      

    Creating and publishing a package link

  • bower is mostly for front-end packages, but there are exceptions

      

    Creating and publishing a package link

05.01.2017 / 20:18
9

NPM is for projects in nodejs, if you are developing some project with NodeJS the best option is this.

Bower is for web project dependencies, focused on front-end, like jQuery (Bower needs nodejs to execute)

and Composer is a dependency manager focused on PHP.

There is another link in the stackoverflow in English, where someone explains the difference a little better, follows the link: link

    
05.01.2017 / 20:18
5

npm is the nodejs package manager. Used in javascript projects and takes care of the dependencies of javascript modules of your project. See more at npmjs

composer is the backend package manager, most used in PHP, but there are other projects and CMS like drupal that composer takes care of all the dependency of project modules. See more at composer

bower is a front-end component manager, you need to put it with npm. Manages the front-end dependencies of your project. See more at bower.io.

    
05.01.2017 / 20:31