Deploying Composer (PHP’s dependency manager) inside an intranet is usually about avoiding dependency download problems caused by restricted outside network access. An intranet Composer deployment mainly comes down to configuring a private Composer repository, or using a local proxy mirror to speed up and manage dependencies.
1. Define Dependencies with composer.json
First, make sure your composer.json file contains all of the project’s dependencies and that package versions and sources are configured correctly.1
2
3
4
5
6{
"name": "vendor/project",
"require": {
"monolog/monolog": "^2.0"
}
}
2. Use a Proxy Mirror
Since the intranet can’t reach Composer’s official package repository directly, the usual approach is to use a domestic mirror or to set up a proxy server; common options include the Alibaba Cloud Composer mirror or a private mirror repository.
2.1 Use a Domestic Mirror Source
You can speed up dependency downloads by configuring Composer to use a domestic mirror. In Composer, you can set one up with the command below:1
composer config repo.packagist composer https://mirrors.aliyun.com/composer/
This command swaps the packagist.org source for the Alibaba Cloud mirror.
You can also force the mirror source by configuring it in the composer.json file:
1 | { |
That way, every time you run composer install, dependencies are downloaded from the Alibaba Cloud mirror.
2.2 Set Up Your Own Composer Mirror Proxy
If you want full control over package management inside your company, you can build your own Composer mirror proxy. Common choices include:
- Satis: a tool provided by the Composer team for building private Composer repositories.
- Private Packagist: a commercial solution purpose-built for managing Composer packages in a private environment.
- Sinopia (an npm repository proxy tool): can be used as a private Composer repository proxy.
2.2.1 Building a Private Composer Repository with Satis
Satis is a lightweight tool provided by the Composer team specifically for creating private Composer repositories. Using Satis, you can cache the dependencies commonly used inside your intranet and serve them to your projects.
Steps:
- Install Satis:
Install Satis with Composer:
1 | composer require composer/satis |
- Configure Satis:
Create a satis.json config file on your server and specify the package sources you want to host.
1 | { |
- Generate the static assets:
Run the following command to generate the static Composer packages:
1 | php bin/satis build satis.json /path/to/output |
- Serve them:
You can serve the static assets through a web server (such as Nginx or Apache). That way, other projects can pull dependencies from your internal Satis repository.
2.2.2 Configure Composer to Use a Private Repository
Configure the private repository in composer.json (for example, the Satis repository your company set up internally).
1 | { |
Composer will then pull dependencies from the private repository you configured.
3. Install Composer Dependencies Offline
If the intranet has no outside network access at all, you can also download the dependency packages on a machine that does have internet access and then import them onto the intranet machine for installation.
3.1 Download Dependencies on a Machine with Internet Access
Run composer install on a machine that can reach the internet.
Once the download finishes, copy the vendor directory and the composer.lock file to the same location on the intranet server.
3.2 Use the —prefer-dist Flag
You can also use composer install —prefer-dist to download packages in .tar.gz or .zip format, which makes offline installation convenient.
3.3 Configure COMPOSER_HOME
If you want the intranet machine to use locally cached packages, you can set the COMPOSER_HOME environment variable to specify Composer’s cache directory.
1 | export COMPOSER_HOME=/path/to/composer/cache |
Then copy the cache directory to the intranet machine and make sure Composer can use that cache.
4. Other Considerations
- Proxy configuration: if the intranet can reach the outside world through an HTTP proxy, make sure Composer is configured to use a proxy. Set the proxy in composer.json, or specify it with environment variables:
1 | export HTTP_PROXY=http://proxy.example.com:8080 |
- Private package permissions: if you use private Composer repositories or GitHub repositories, remember to set up authentication (for example, storing a GitHub token in an auth.json file).

