Satis Documentation

repository·main·Indexed 25 days ago

https://github.com/composer/satis

Satis is a static Composer repository generator that allows PHP developers to create private package repositories for better distribution control, improved security, and faster installations. It supports installation via source, Docker, or as a Composer plugin, and provides tools for building repositories, managing package archives, and configuring repository metadata via JSON.

Tokens
6K
Snippets
19
Records
39
Agent score
84%

What's inside Satis

  1. Build a Satis repository

    main

    Run the build command to generate the package information and web outputs.

    If your repositories are hosted on private services like GitHub, ensure your server has an SSH key configured for access. Use the --no-interaction (or -n) flag to prevent the process from hanging on password prompts, which is essential for cron jobs and CI/CD environments.

  2. Run Satis as a Docker container

    main

    You can run Satis using Docker Hub (composer/satis) or the GitHub container registry (ghcr.io/composer/satis). The following command runs the build process while mounting your current directory to /build and your host's Composer cache to /composer to improve performance.

    # Pull the image
    docker pull composer/satis
    
    # Run the build
    docker run --rm --init -it \
      --user $(id -u):$(id -g) \
      --volume $(pwd):/build \
      --volume "${COMPOSER_HOME:-$HOME/.composer}:/composer" \
      composer/satis build <configuration-file> <output-directory>
  3. Set up a Satis configuration

    main

    To use Satis, create a JSON configuration file (defaulting to satis.json) that defines the repositories you want to curate. You can either use "require-all": true to include all versions of all packages found in the listed repositories, or use the "require" key to cherry-pick specific packages and versions using standard Composer constraints.

    {
        "name": "My Repository",
        "homepage": "http://packages.example.org",
        "repositories": [
            { "type": "vcs", "url": "https://github.com/mycompany/privaterepo" },
            { "type": "vcs", "url": "http://svn.example.org/private/repo" },
            { "type": "vcs", "url": "https://github.com/mycompany/privaterepo2" }
        ],
        "require-all": true
    }
  4. Run Satis using Docker

    main

    You can run Satis inside a Docker container. Ensure you mount your workspace directory to the /build directory inside the container to persist or access your repository data.

    docker pull composer/satis
    docker run --rm -it -v <workspace>:/build composer/satis
  5. Use a Satis repository in your Composer projects

    main

    To use a Satis repository in your project, add it to the repositories section of your composer.json. This allows you to require private packages from your central Satis instance without needing to define every individual repository in every project.

    {
        "repositories": [
            { "type": "composer", "url": "http://packages.example.org/" }
        ],
        "require": {
            "company/package": "1.2.0",
            "company/package2": "1.5.2",
            "company/package3": "dev-master"
        }
    }
  6. Authenticate with password-protected repositories

    main

    When your private repositories require a username and password, you can store credentials in COMPOSER_HOME/auth.json (defaults to ~/.composer or %APPDATA%/Composer on Windows) or in a project-local auth.json next to composer.json.

    To configure credentials non-interactively (e.g., on a production machine), use the composer config command:

    composer config http-basic.example.org username password

    Use the --global or -g flag to make the credentials available globally.

  7. Install and run Satis from source

    main
    To use Satis directly from source, ensure you have a compatible PHP version installed (check composer.json for requirements). You can install Satis as a project and then use the build command to generate your repository.
  8. Secure Satis repositories with SSH, SSL, or HTTP Headers

    main

    You can secure your private Satis repository by using the options parameter in your composer.json to pass connection settings to the server.

    SSH (requires SSH2 PECL extension)

    Use the ssh2.sftp:// protocol and provide username, pubkey_file, and privkey_file under the ssh2 key.

    SSL/TLS (HTTPS)

    Use a client certificate by providing the local_cert path under the ssl key.

    Custom HTTP Headers

    Use the http key with a header array to pass authentication tokens.

    // SSH Example
    {
        "repositories": [
            {
                "type": "composer",
                "url": "ssh2.sftp://example.org",
                "options": {
                    "ssh2": {
                        "username": "composer",
                        "pubkey_file": "/home/composer/.ssh/id_rsa.pub",
                        "privkey_file": "/home/composer/.ssh/id_rsa"
                    }
                }
            }
        ]
    }
    
    // SSL/TLS Example
    {
        "repositories": [
            {
                "type": "composer",
                "url": "https://example.org",
                "options": {
                    "ssl": {
                        "local_cert": "/home/composer/.ssl/composer.pem"
                    }
                }
            }
        ]
    }
    
    // HTTP Header Example
    {
        "repositories": [
            {
                "type": "composer",
                "url": "https://example.org",
                "options": {
                    "http": {
                        "header": ["API-TOKEN: YOUR-API-TOKEN"]
                    }
                }
            }
        ]
    }
  9. Perform partial updates for specific packages

    main

    To reduce rebuild time, you can instruct Satis to only rebuild specific packages by passing their names as arguments at the end of the build command. Note that Satis will still scan all VCS repositories to locate these packages unless repository names are explicitly defined.

    php bin/satis build satis.json web/ this/package that/other-package
  10. Optimize VCS scanning with repository names

    main

    When using vcs type repositories, you can provide a "name" key in the configuration. This allows Satis to more efficiently map packages to repositories, which is useful when performing partial updates.

    {
        "repositories": [
            {
                "name": "company/privaterepo",
                "type": "vcs",
                "url": "https://github.com/mycompany/privaterepo"
            }
        ]
    }