Composer Repositories

Composer Repositories

Composer is a tool for dependency management in PHP. Declare the libraries your project depends on and Composer installs and updates them for you.

See Composer's documentation for details.

Note
Nexus Repository native Composer support does not support migration from the Community plugin.

Note
Nexus Repository supports only the Composer v2 protocol. Repositories that serve Composer v1 metadata, such as https://repo.magento.com, cannot be proxied.

Proxying Composer Repositories

Composer proxy repositories cache packages from privately hosted and public repositories.

To proxy a Composer repository, create a new Composer (proxy) as documented in Repository Management.

Minimal configuration steps are:

Note
Ensure you are using the latest packagist url as the required format has changed.

Configure Composer Client

Update the composer.json file saved in the ~/.composer folder and set the repositories section to include a link to the Composer proxy in the Nexus Repository.

Example:

"repositories": [
 {  
   "type": "composer",
   "url": "localhost:8081/repository/composer-proxy" 
 }
],

Disabling Packagist.org

Disable the default Packagist.org repository by adding the following to your composer.json:

{
  "repositories": [
    {
      "repo.packagist.org": false
    }
  ]
}

Configuring Authorization

When Nexus Repository requires authorization, Composer should have an auth.json file saved in the ~/.composer folder. Below is an example of setting the authorization configuration:

{
  "http-basic": {
    "localhost:8081": {
      "username": "admin",
      "password": "admin123"
    }
  }
}

Update the Repository_Base_URL to the base URL for your Nexus Repository.

See the Composer documentation on managing authentication.

Using an Unsecured HTTP Repository Server

Composer is configured by default only to allow secured proxies. This may be disabled when your repository is not configured with HTTPS. Add the following to your composer.json:

{
  "config": {
    "secure-http": false
  }
}

See the Composer documentation for details.

Clearing the Local Cache to Pull From Nexus Repository

Composer caches dependencies to speed up builds and reduce network usage. Run the following to clear the local cache:

composer clear-cache

Search results

No results found