Adding composer #27

Merged
merged 3 commits into from Nov 9, 2012

Conversation

Projects
None yet
5 participants
Contributor

Sgoettschkes commented Oct 11, 2012

Adding composer definition and a binary which includes composer autoloader
fixes #24

I could not user zetacomponents/console-toosl version 1.8 as it does not have the correct composer.json. I didn't try any version in between.
Tests are passing and it works with my projects, so I guess it's ok.

Sgoettschkes added some commits Oct 11, 2012

Adding composer definition and a binary which includes composer autol…
…oader


fixes #24

I could not user zetacomponents/console-toosl version 1.8 as it does not have the correct composer.json.
I didn't try any version in between.
Tests are passing and it works with my projects, so I guess it's ok.
Changing version of dependency console-tools
For some reason I messed up with the version for zetacomponents/console-tools
There is no version 1.8 so I am using dev-master.

Can you please explain why you want to install a tool such as PHPLOC through Composer? Why not just download the PHAR and use that?

Contributor

Sgoettschkes commented Oct 12, 2012

I think its way easier to have all dependencies defined in one place, especially as composer can define require and require-dev to seperate libraries which are only used in development/testing (as phploc is in most cases).

And having another way of installing it seems like a good thing, leaving the choice up to the user.

Sorry, but did you actually read my comment?

Contributor

Sgoettschkes commented Oct 12, 2012

Maybe I do not understand the question. Is there any advantage from using a phar instead of composer? As most tools (phing, pdepend, phpmd, phpunit) are avaiable through composer I thought it would be good to have them all in there so one can use one tool (composer/packagist).

Your comment on #24 actually encouraged me to go ahead and implement it.

Contributor

ihabunek commented Oct 14, 2012

Here's a my reasons for Composer:

Let's say I want to setup a development environment for my project. This is something I do relatively regularly. The usual way is to go to the homepage of each vendor, and download the latest phar (or alternatively install via PEAR). There's quite a few dev libraries I use on a regular basis (phpunit, phploc, apigen, php_codesniffer and others) so this takes a while.

Using Composer, I have a list of required development packages specified in my composer.json, and all I need to do is run composer install --dev. And for the next project, just copy/paste and you're set.

The advantage of Composer over phars is that it's much quicker to setup.

The advantage of Composer over PEAR is that you can have different versions of packages installed for each project. Some of my projects may require, for example, an older version of PHPUnit because I have not yet updated the tests to work with the new version.

I saw in several projects that you're not so hot about using Composer. Frankly, I don't see that you lose anything by supporting composer. It doesn't require maintenance and the required change to the project is minimal. And you make me and others happy. :)

Thank you for taking the time to explain why you think it makes sense add Composer support to PHPLOC. I will review the patch shortly.

Contributor

ihabunek commented Oct 14, 2012

I would strongly recommend that you do not specify a "version" in composer.json.

Packagist (the default package repository used by Composer) will automatically detect existing versions by scanning the tags and branches in your git repository. More here:
http://getcomposer.org/doc/02-libraries.md#tags

The process you're looking at is:

  1. Add composer.json to your project root.
  2. Create a new package on Packagist by just giving it the URL to your github repo (very simple, no need to upload anything).
  3. In the github repo, enable the Packagist hook which automatically sync Packagist with the repo.

And you're done. When creating a new version, you just create a git tag, and Packagist will interpret it as a new version.

Additionally, the patch contains a runnable file (bin/phploc). This is a copy of phploc.php from your project root. The reason for this is that Composer expects a runnable PHP file which does not have a ".php" extension. On install, Composer will automatically generate vendor/bin/phploc (linux script) and vendor/bin/phploc.bat (windows script).

This file is referenced in composer.json:

"bin": ["bin/phploc"]
Contributor

Sgoettschkes commented Oct 14, 2012

I removed the version from the composer.json.

Regarding the binary: Actually it's a bit different as it uses the autoload.php from composer and not loads anything on it's own.

Parad0X commented Oct 23, 2012

+1 I also would love to have this available through composer.

+1 @sebastianbergmann could you review and focus on getting this out of the box?
Patch seems ok to me.

@sebastianbergmann sebastianbergmann merged commit 8e43a47 into sebastianbergmann:master Nov 9, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment