Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I synchronize or mirror dependencies from packagist.org with my own Composer Satis installation?

We have our own Satis repository, we can store there our own dependencies. This works fine.

But if a developer uses a package that is not within in our own repository, then Composer will fetch it from GitHub through packagist.org (as a fallback).

But we do not want to be dependent on packagist.org. All dependencies should be downloaded from our own repository.

What we like to know, if its possible that Satis download a package from Packagist, if it is not locally available yet, and then store it and add it to Satis own repository automatically .

This way we do not have to manually add the dependencies to the Satis repository.

like image 973
Niborb Avatar asked Aug 01 '12 12:08

Niborb


People also ask

How to add private Packagist as a repository in composer?

So you have to add Private Packagist as a repository to your composer.json file and you need to disable packagist.org because public packages will be mirrored through Private Packagist, too. Run composer update mirrors to mirror all dependency packages into Private Packagist.

How do I install satis in composer?

Simple static Composer repository generator. Satis requires a recent PHP version, it does not run with unsupported PHP versions. Check the composer.json file for details. Install satis: composer create-project composer/satis:dev-main Build a repository: php bin/satis build <configuration-file> <output-directory>

How do I add custom package definitions in composer?

Custom package definitions in your composer.json can be added via Add Package -> Custom Package. In the textarea you are then able to paste the entire package definition and select a credential if one is necessary to access the zip files.

Where can I find packages for composer?

Find packages on Packagist. Follow @packagist or @seldaek on Twitter for announcements, or check the #composerphp hashtag. For support, Stack Overflow offers a good collection of Composer related questions, or you can use the GitHub discussions.


2 Answers

Satis now supports this.

Just follow the Satis setup instructions and add the following to your configuration file (which is named satis.json by default). Update prefix-url and require as appropriate.

{
    "repositories": [
        { "type": "composer", "url": "https://packagist.org" }
    ],
    "require-dependencies": true,
    "require": {
        {{your application dependencies from composer.json}}
    },
    "archive": {
        "directory": "dist",
        "prefix-url": "{{your server}}",
        "skip-dev": true
    }
}

Then, you can create your Satis repository like normal:

php bin/satis build <configuration file> <build dir>

Now, your Satis repository will satisfy all of your application's dependencies.


Note: the first run might take a while. Subsequent runs are much faster. Also, note that Satis uses /tmp for its cache. On a small memory system where /tmp is backed by tmpfs, you might need to increase the space /tmp has available if you have a large dependency tree.

You might also want to disable the Packagist repository in your project's composer.json file to enforce that all dependencies come from your Satis repository. To do this, add:

{
    "repositories": [
        {
            "packagist": false
        }
    ]
}

to your project's composer.json.

like image 186
rynemccall Avatar answered Sep 30 '22 04:09

rynemccall


You can use broker to achieve this for now. Most likely this capability will be added to satis itself down the line.

like image 23
Seldaek Avatar answered Sep 30 '22 03:09

Seldaek