Lucia
Lucia

Reputation: 4767

Load vendor dependencies with composer.json

I have recently forked robmorgan/phinx project and modified the composer.json file in my project to use the forked version:

{
    "name": "...",
    "description": "...",

    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "lube8uy/phinx",
        "version": "master",
                "source": {
                    "url": "https://github.com/lube8uy/phinx.git",
                    "type": "git",
                    "reference": "master"
                }
            }
        }
    ],
    "require": {
    "php": ">=5.3.0",
        "lube8uy/phinx": "dev-master"
    }
}

First question: additional vendors

Now, when I load the composer.json file in my project I get this forked version correctly. What I don't know is how to load the dependencies from the phinx project itself: https://github.com/lube8uy/phinx/blob/master/composer.json

If I use the original packagist source everything works fine and I got all the dependencies, but now that I use my own repository I can't get them.

Second question: updates

How can I receive the modifications I made to my github source? I made some modifications, pushed them to the correct branch, then I run composer update but nothing was updated... what am I doing wrong?

Thank you very much

Upvotes: 1

Views: 1914

Answers (1)

thormeier
thormeier

Reputation: 672

For your first question:

Try to require it as a VCS repository (Version Control System, see composer doc on vcs repositories), like the following:

{
    "name": "...",
    "description": "...",
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/lube8uy/phinx"
        }
    ],
    "require": {
        "php": ">=5.3.0",
        "robmorgan/phinx": "dev-master"
    }
}

It now requires the package robmorgan/phinx which is found at https://github.com/lube8uy/phinx which is the desired fork. It still has the original name robmorgan/phinx but is found at a different location.

It still has the same name because of the package name in its composer.json. If you want to change the name to lube8ye/phinx, change it in the composer.json in the fork.

For your second question:

The changes made in a package you require via composer should be updated automatically when you execute php composer.phar update in your project. If this does not work, try to force composer to require a specific commit by adding the commit hash after dev-master in your require section like so:

    "require": {
        "robmorgan/phinx": "dev-master#1234abcd"
    }

Whereat 1234abcd is the hash of the desired commit.

Also: Try clearing composer's cache by deleting the folders content to avoid loading a cached version (see composer doc on COMPOSER_CACHE_DIR)

Upvotes: 3

Related Questions