Home > Backend Development > PHP Tutorial > Local Composer for Everyone! A Conference-Friendly Satis Setup

Local Composer for Everyone! A Conference-Friendly Satis Setup

Christopher Nolan
Release: 2025-02-10 12:13:10
Original
901 people have browsed it

This article explains how to set up a local Satis instance to host Composer packages over a network, enabling offline package retrieval. It eliminates the need for an internet connection for accessing packages.

Local Composer for Everyone! A Conference-Friendly Satis Setup

Key Concepts:

  • Local Package Hosting: Satis creates a local repository, allowing network users to download packages without internet access.
  • satis.json Configuration: This file specifies repositories, versions, and download locations. It lists the necessary packages.
  • Time-Consuming Setup: Satis downloads all package versions and their binaries. Specifying exact versions is recommended for efficiency.
  • Offline/Unstable Network Use Cases: Ideal for conferences, offline development, or as a backup for corporate Packagist access.

The author uses Homestead Improved for the setup, but a standard PHP environment or Docker is also suitable. A shared port (e.g., 6789) needs to be configured in Homestead.yaml.

Satis Setup Steps:

  1. Install Satis: composer create-project composer/satis --stability=dev --keep-vcs
  2. Create satis.json: This file lists the required packages (using their full Github URLs for VCS repositories). The example includes many packages:
{
    "name": "NoFW Websc",
    "homepage": "http://nofw.websc:6789",
    "repositories": [
        // ... (List of Github repositories) ...
    ],
    "require-all": true,
    "require-dependencies": true,
    "require-dev-dependencies": true,
    "archive": { "directory": "dist" }
}
Copy after login
<code>*Note:  `require-all` is inefficient.  Specifying exact package versions is advised for faster builds.*</code>
Copy after login
  1. Build the Repository: php bin/satis build satis.json web/ (This may require a Github token).
  2. Host the Repository: Start a simple PHP web server: cd web; php -S 0.0.0.0:6789
  3. Access the Repository: Access via the host machine's IP address and port (e.g., 192.168.5.11:6789 or a hostname).

Local Composer for Everyone! A Conference-Friendly Satis Setup

Client-Side Usage:

  1. Add Host Entry (if using hostname): Add the hostname and IP address to the client machine's /etc/hosts file.
  2. Add Repository to composer.json:
{
    "repositories": [
        {
            "type": "composer",
            "url": "http://nofw.websc:6789"
        }
    ],
    "config": { "secure-http": false }
}
Copy after login
  1. Install Packages: composer require twig/twig beelab/bowerphp

Local Composer for Everyone! A Conference-Friendly Satis Setup

Troubleshooting:

  • Windows Intranet Issues: Ensure all devices are on the same router/extender.
  • Connection Refused: Verify port forwarding in Homestead.yaml or Vagrantfile.
  • Alternatives to Ngrok/Localtunnel: These require internet access; Satis is for local network sharing.

Conclusion:

Satis provides a simple way to create a local Composer repository, ideal for offline or unstable network environments. It's useful for conferences, corporate backups, and even portable setups using a Raspberry Pi.

Frequently Asked Questions (FAQs): (The original FAQs are included in the output, as they are relevant and don't need modification for paraphrasing.)

The above is the detailed content of Local Composer for Everyone! A Conference-Friendly Satis Setup. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template