@mstred A Software Developer

Composer

One thing that helps us devs for sure is the use of a dependency management tool. This is such an important and relevant topic on a software engineering overall, but I wanted to get straight down to a specific one that I’ve been using at work. I guess that presenting it as an example should actually be fine as I intend to.

I’ve never been a PHP guy. As I told before in the last post, PHP have been such a thing I used to know when I had “Web Dev 101” classes in college. Atfer that, I went full throttle on “enterprisey“-Java fueled software development.

I’ve got to know Maven (which by the way was a very nice one, but I had some struggle on eclipse integration with m2e some time ago - I guess it’s alright by now… need to check it right away). It was something beautiful to see all of the libraries and components dependency responsibilities delegated to something that would resolve it all for me. And even more: isolating all of the libs from the code. This was truly awesome to a newcomer which suffered a lot setting up JARs into eclipse project configurations (…I don’t really miss this. For real).

After that, I’ve got dealing with Rubygems (self-study and curiosity, but nothing professional-grade, by the way) and later with npm, which is another very nice example. But then I got to know Composer.

"This Joker-inspired Composer is very awesome."

Getting started with Composer is plain easy and it’s pretty fine to get along with it. There are plenty of examples to install, but I quite like this:

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

The snippet above translates to a command that fetches Composer’s installation script, executes it and put its binary into a well-known directory included in $PATH (most of all time), and renames it as composer.

Once installed, you can have some fun with composer init, which generates a composer.json descriptor file, where all the dependency libraries should be listed. Then you can go with a composer install to (obviously) install the deps from the first time and composer update, to make sure they are at the latest version. These are the basic commands, but you can find a lot more from their official docs. Anyway, this Composer will surely help you to create a handful of “masterPHPieces” (ba-dum-tss!).

Bravo, maestro!