Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/harness/harness-cli/llms.txt

Use this file to discover all available pages before exploring further.

Harness Artifact Registry provides support for PHP Composer packages, allowing you to host private PHP libraries.

Overview

Composer registry features:
  • Standard Composer repository protocol
  • Package metadata from composer.json
  • Version management
  • PSR-4 autoloading support
  • Integration with Composer CLI

Pushing Composer packages

Use the hc artifact push composer command:
hc artifact push composer <registry-name> <package-file-path> \
  --pkg-url <pkg-url>
Package files are typically .zip archives containing your PHP source code and composer.json

Creating Composer packages

1

Create composer.json

Define your package metadata:
composer.json
{
  "name": "vendor/package-name",
  "description": "My PHP library",
  "version": "1.0.0",
  "type": "library",
  "require": {
    "php": ">=8.0"
  },
  "autoload": {
    "psr-4": {
      "Vendor\\Package\\": "src/"
    }
  }
}
2

Package your library

Create a zip archive:
zip -r vendor-package-1.0.0.zip . -x '*.git*' 'vendor/*' 'tests/*'
3

Upload to registry

Push the package:
hc artifact push composer my-registry ./vendor-package-1.0.0.zip \
  --pkg-url https://app.harness.io/registry/pkg

Installing Composer packages

Configure Composer to use your Harness registry:

In composer.json

Add the repository to your project’s composer.json:
composer.json
{
  "repositories": [
    {
      "type": "composer",
      "url": "https://<registry-url>/packages.json"
    }
  ],
  "require": {
    "vendor/package-name": "^1.0"
  }
}

Authentication

Configure authentication in auth.json:
auth.json
{
  "http-basic": {
    "<registry-url>": {
      "username": "your-username",
      "password": "your-harness-token"
    }
  }
}
Add auth.json to .gitignore to avoid committing credentials

Install packages

composer install

Examples

# Create and push a package
zip -r mypackage-1.0.0.zip . -x '*.git*' 'vendor/*'
hc artifact push composer my-registry ./mypackage-1.0.0.zip \
  --pkg-url https://app.harness.io/registry/pkg

Composer.json requirements

Minimal composer.json:
{
  "name": "vendor/package",
  "version": "1.0.0",
  "type": "library"
}
Recommended fields:
{
  "name": "vendor/package",
  "description": "Package description",
  "version": "1.0.0",
  "type": "library",
  "license": "MIT",
  "authors": [
    {
      "name": "Your Name",
      "email": "you@example.com"
    }
  ],
  "require": {
    "php": ">=8.0"
  },
  "autoload": {
    "psr-4": {
      "Vendor\\Package\\": "src/"
    }
  }
}

Package naming

Composer packages follow the convention:
vendor/package-name
Examples:
  • acme/framework
  • mycompany/utils
  • mypackage ❌ (missing vendor)

CI/CD integration

- name: Package and publish
  run: |
    zip -r package-${{ github.ref_name }}.zip . -x '*.git*' 'vendor/*'
    hc artifact push composer my-registry ./package-*.zip \
      --pkg-url https://app.harness.io/registry/pkg
  env:
    HARNESS_API_KEY: ${{ secrets.HARNESS_API_KEY }}

Troubleshooting

Validate your composer.json:
composer validate
Ensure the package name in composer.json matches what you’re requiring:
# Check uploaded packages
hc artifact list --registry my-registry
Verify your auth.json configuration:
# Test authentication
composer diagnose

See also

Build docs developers (and LLMs) love