phpcomposer-phpsatis

Composer - Set local repo as the first preference


I have just setup a local repo on my PC, and its working very well.

But the problem is when I am installing a package the composer tool checks the packagist repo first instead of my local repo. I want the local repo to be checked first. How can fix this??.

here is my global config.json

{
"repositories": {
    "local": {
        "type": "composer",
        "url": "http://localhost:9090"
    }
}

Any help?


Solution

  • Is Satis running?

    Please browse http://localhost:9090 to make that sure.

    Satis needs to run properly and must list your packages, before you can work with composer.json (or even move things to config.json).

    The basic guide for setting up Satis is over here: https://getcomposer.org/doc/articles/handling-private-packages-with-satis.md#satis .

    If you can't get Satis running, post your satis.json.


    You could try removing the key local from config.json and add "packagist": false instead (to disable Packagist lookups).

    {
        "repositories": [
            { "packagist": false },
            {
                "type": "composer",
                "url": "http://localhost:9090"
            }
        ]
    }
    

    I think the solution is to combine - the setting "packagist":false on your projects - with "require-dependencies": true on your satis config.

    This means that all packages you require are not fetched directly by Composer from Packagist (its off), but indirectly via the Satis server.

    Satis will contact Packagist and download the packages to your Satis space (local package cache) and Composer grabs them from there.

    I cannot disable packagist since I need it for other packages.

    When you allow Satis to fetch them, you can disable packagist globally for projects. The directives require-dependencies and require-all might help.