0

I'm a bit confused about using Composer.

I have built my own package manager, that uses a config-file and a large SVN-repo that contains all possible libraries (both PHP and Javascript / CSS) I need in several different projects. I download these packages myself from the library websites.

Now I'm trying to use Composer instead, since I like the automatic dependency checking and want to use something that everybody else does. But how do you decide what packages are best?

For example, for CodeMirror, I used to download the latest stable version from https://codemirror.net/ . But when I look in Packagist I see so many different versions that I don't know which to choose. It seems everybody can create new packages for Composer ? I just need the official ones.

So, how do you guys pick the packages you need?

Dylan
  • 9,129
  • 20
  • 96
  • 153
  • 1
    CodeMirror looks to be a Javascript project... Packagist is *The **PHP** Package Repository* – Sverri M. Olsen Dec 29 '15 at 13:05
  • well, it contains several Javascript libraries as well, like jQuery, so I thought I could just use it for all packages I need. – Dylan Dec 29 '15 at 13:07
  • 1
    Is it just the JavaScript library you want, or is there some sort of PHP integration they supply as well. Most of the time we fall back on CDNs for JS, or paste the library into the web folder of the project. – Flosculus Dec 29 '15 at 13:09
  • What you are probably looking for is something like [NPM](https://www.npmjs.com/), or a build tool like [Gulp](http://gulpjs.com/) or [Grunt](http://gruntjs.com/). – Sverri M. Olsen Dec 29 '15 at 13:23

1 Answers1

0

To answer your question directly, for any component you want to import into your project, the way to find the "canonical" source - as opposed to various forks - is to go back to the original source and see what their usage/install instructions suggest. If they support a Packagist-based install, they will usually say so. If not, but there is a composer.json in their (typically) Github repository, then you can add the repository to your composer.json and then require the package as normal.

However, more generally, I think there is some confusion about what Composer really does. As noted in the comments, Composer is a dependency manager for PHP. Packagist is the primary repository for composer-managed packages. The CodeMirror library you cited is fundamentally a javascript library.

Now it's true that if you search for "codemirror" on Packagist, you will see lots of results there, some of which are labeled as Javascript components. But they are primarily:

Bottom line: Composer is primarily used for importing PHP packages. It takes some gymnastics - like the Component Installer for Composer noted above - to make it usable/helpful for non-PHP packages.

Community
  • 1
  • 1
David Weinraub
  • 14,144
  • 4
  • 42
  • 64