Configure Composer to use Nexus

Nexus Repository OSS ( open source repository)

Table Of Contents

1 INSTALL NEXUS USING DOCKER

2 USING COMPOSER WITH NEXUS

1- INSTALL NEXUS USING DOCKER

Clone & Build with Docker

git clone https://github.com/sonatype-nexus-community/nexus-repository-composer.gitdocker build -t nexus-repository-composer .

Run as a Docker container

docker run -d -p 8081:8081 --name nexus-repository-composer nexus-repository-composer
docker exec -it nexus-repository-composer /bin/bash $ cat /nexus-data/admin.password

1–1 Proxying Composer Repositories

  • Define ‘Name’
  • Define URL for ‘Remote storage’ e.g. https://packagist.org/
  • Select a ‘Blob store’ for ‘Storage’

1–2 Hosting Composer Repositories

  • Define ‘Name’ — e.g. composer-hosted
  • Select ‘Blob store’ for ‘Storage'

2- Using Composer With Nexus3

to configure composer with nexus we must proceed with 2 steps :

composer config repo.myrepo composer https://localhost:8081/repository/packagist/
{
"name": "href/myrepo",
"require-dev": {
"predis/predis": "^1.1"
},
"authors": [
{
"name": "NHAILA Achraf",
"email": "achraf.nhaila@gmail.com"
}
],
"require": {
"twbs/bootstrap": "5.0.2"
},
"repositories": {
"repo-php": {
"type": "composer",
"url": "https://localhost:8280/repository/COMPOSER-Repo/"
},
"packagist": false
}
}
{
"http-basic": {
"nexus.machine.com": {
"username": "username",
"password": "password"
}
}
}

Now, when you run composer install, composer will try to get their dependencies from Nexus, and if Nexus does not have them, it will look for them on the Internet.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store