# 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](https://getcomposer.org/) 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](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](https://help.sonatype.com/en/repository-management.html "Repository Management").

Minimal configuration steps are:

- Define the proxy name. e.g., `composer-proxy`
- Define the URL for remote storage. e.g., `https://repo.packagist.org/`

**Note**  
Ensure you are using the latest packagist url as the required format has changed.
- Select a blob store for storage

## 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](https://getcomposer.org/doc/articles/authentication-for-private-packages.md).

### 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](https://getcomposer.org/doc/06-config.md#secure-http) 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
