composer-phpmomentjspackagistsatis

How to use composer with a non-packagist github project containing a packages.json


I want to put https://github.com/timrwood/moment into my composer.json for easy maintenance.

It's not an official packagist project (of course, as it's not PHP), but it contains a packages.json for nodejs. Can I use this in my composer.json?

I tried this, but it didn't work:

{
    "repositories": {
        "timrwood/moment": {
           "type": "git",
           "url": "git://github.com/timrwood/moment.git"
        }
    }
}

It throws an error message saying "No valid composer.json was found in any branch or tag of git://github.com/timrwood/moment.git, could not load a package from it."

And it is lacking the version string to define the version I want to use...

Can anyone help here?

Or shouldn't I use composer here at all cause I'm mixing JS and PHP?


Solution

  • Composer only manages composer packages. It does not know how to parse a package.json file. There are different approaches to this problem. Composer may be able to deal with frontend dependencies in the future.

    For the time being I'd recommend using a separate dependency manager for your JavaScript dependencies. Either NPM or something like jam or ender.