Include libraries with Composer, NPM, or Bower

I recently got into Composer, NPM and Bower. I don't have much overlap between their capabilities, and I was wondering if my approach is right? If not, what should I do?

I usually run my PHP projects by setting up composer to load my PHP libraries and dependencies. After that, I use NPM to install Gulp and all the Gulp plugins that I use. Finally, I am using Bower to get JS and CSS libraries.

Most of them can be downloaded from GitHub, so in theory I could use Composer to install my JS / CSS or Bower to download my PHP. I am pretty much tuned in to Composer for its autoloading capabilities, so I guess my question is, should I reset Bower?

Currently when I deploy I go through my repo and call npm install

which installs Gulp etc. In mine package.json

I am using "scripts": {"install": "gulp install"}

which launches my task install

in mine gulpfile.js

. This is loaded into plugins gulp-composer

and gulp-bower

which launch Composer and Bower installations.

+3


source to share


1 answer


They are all pretty much the same, the difference is in their default package list (NPM is purely NodeJS, Composer is purely PHP, Bower is purely js / css, etc.) and the language they are written in.

However, they all have one limitation: they can only install packages in one place. This means that you cannot install some/php-framework

in vendor/

and my-css-framework

in web/

.



Place is very important: you often want your PHP code / NodeJS libraries to exist outside of the public root, but your assets must be inside your shared root.

I think it's a very good practice if you can use every dependency manager for the language it was developed in too (for example Composer also uses some PHP-specific things like autoloading, while NPM does some NodeJS stuff).

+2


source







All Articles