PHPackages                             aysnc/composer-env-auth - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. aysnc/composer-env-auth

ActiveComposer-plugin[Authentication &amp; Authorization](/categories/authentication)

aysnc/composer-env-auth
=======================

Composer plugin that reads authentication credentials from environment variables and .env files

0.1.0(8mo ago)00MITPHPPHP ^8.2

Since Sep 6Pushed 4mo agoCompare

[ Source](https://github.com/Aysnc-Labs/composer-env-auth)[ Packagist](https://packagist.org/packages/aysnc/composer-env-auth)[ Docs](https://github.com/Aysnc-Labs/composer-env-auth)[ RSS](/packages/aysnc-composer-env-auth/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Composer Environment Authentication Plugin
==========================================

[](#composer-environment-authentication-plugin)

[![Maintenance](https://camo.githubusercontent.com/9f9520637e3eaf34c2a45cb16bd6adf93e17366bb9c706a7d20b003e653afbcd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4163746976656c792532304d61696e7461696e65642d7965732d677265656e2e737667)](https://camo.githubusercontent.com/9f9520637e3eaf34c2a45cb16bd6adf93e17366bb9c706a7d20b003e653afbcd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4163746976656c792532304d61696e7461696e65642d7965732d677265656e2e737667)

> **Streamline your Composer authentication with environment variables**

Are you managing separate `.env` files alongside `auth.json` files for your Composer authentication? This plugin eliminates that redundancy by bringing industry-standard environment variable support directly to Composer's authentication system.

While we await native environment variable support in Composer core, this plugin bridges the gap by allowing you to store all your authentication credentials securely in environment variables — just like every other modern development tool.

Features
--------

[](#features)

- 🔐 **Unified Authentication**: Store all credentials in environment variables
- 🚀 **Zero Configuration**: Works automatically once installed
- 🎯 **Multiple Auth Types**: Supports GitHub OAuth, GitLab tokens, and HTTP Basic auth
- 📁 **Project-Aware**: Automatically finds your project root and `.env` file
- ⚡ **Lightweight**: Minimal overhead, maximum convenience

Installation
------------

[](#installation)

Install the plugin as a development dependency in your project. Do this before installing any plugins:

```
composer require --dev aysnc/composer-env-auth
```

Quick Start
-----------

[](#quick-start)

1. **Add authentication configuration to your `composer.json`:**

```
{
    "repositories": [
        {
            "type": "composer",
            "url": "https://connect.advancedcustomfields.com",
            "options": {
                "aysnc/env-auth": {
                    "username": "ACF_USERNAME",
                    "password": "ACF_PASSWORD"
                }
            }
        }
    ]
}
```

2. **Set your credentials in your `.env` file:**

```
ACF_USERNAME=your_acf_license_key
ACF_PASSWORD=your_acf_license_key
```

3. **Run Composer commands as usual:**

```
composer require wpengine/advanced-custom-fields-pro
```

The plugin automatically applies your environment-based authentication!

Configuration Examples
----------------------

[](#configuration-examples)

### HTTP Basic Authentication (Generic)

[](#http-basic-authentication-generic)

```
{
    "repositories": [
        {
            "type": "composer",
            "url": "https://repo.example.com",
            "options": {
                "aysnc/env-auth": {
                    "username": "API_USERNAME",
                    "password": "API_PASSWORD"
                }
            }
        }
    ]
}
```

```
# .env
API_USERNAME=your_username
API_PASSWORD=your_password_or_token
```

### GitHub Personal Access Token

[](#github-personal-access-token)

```
{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/your-org/private-repo.git",
            "options": {
                "aysnc/env-auth": "GITHUB_TOKEN"
            }
        }
    ]
}
```

```
# .env
GITHUB_TOKEN=ghp_your_token_here
```

### GitLab Private Token

[](#gitlab-private-token)

```
{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://gitlab.com/your-org/private-repo.git",
            "options": {
                "aysnc/env-auth": "GITLAB_TOKEN"
            }
        }
    ],
    "require": {
        "your-org/private-package": "^1.0",
        "another-org/repo": "dev-main"
    }
}
```

```
# .env
GITLAB_TOKEN=glpat-your_token_here
```

### Multiple Repositories

[](#multiple-repositories)

```
{
    "repositories": [
        {
            "type": "composer",
            "url": "https://connect.advancedcustomfields.com",
            "options": {
                "aysnc/env-auth": {
                    "username": "ACF_USERNAME",
                    "password": "ACF_PASSWORD"
                }
            }
        },
        {
            "type": "composer",
            "url": "https://repo.custom.com",
            "options": {
                "aysnc/env-auth": {
                    "username": "CUSTOM_USER",
                    "password": "CUSTOM_TOKEN"
                }
            }
        },
        {
            "type": "vcs",
            "url": "https://github.com/org-one/repo.git",
            "options": {
                "aysnc/env-auth": "GITHUB_TOKEN"
            }
        },
        {
            "type": "vcs",
            "url": "https://gitlab.com/org-two/repo.git",
            "options": {
                "aysnc/env-auth": "GITLAB_TOKEN"
            }
        }
    ]
}
```

How It Works
------------

[](#how-it-works)

1. **Plugin Activation**: Automatically activated when Composer initializes
2. **Configuration Discovery**: Scans `composer.json` for repositories with `aysnc/env-auth` options
3. **Environment Resolution**: Resolves variables from system environment and `.env` files
4. **Authentication Configuration**: Dynamically configures Composer's authentication system
5. **Seamless Integration**: Standard Composer commands operate with authenticated access

CI/CD Pipeline Integration
--------------------------

[](#cicd-pipeline-integration)

The plugin seamlessly integrates with CI/CD environments where `.env` files may not be present:

```
# GitHub Actions example
env:
  ACF_USERNAME: ${{ secrets.ACF_USERNAME }}
  ACF_PASSWORD: ${{ secrets.ACF_PASSWORD }}
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}

# GitLab CI example
variables:
  ACF_USERNAME: $ACF_USERNAME
  ACF_PASSWORD: $ACF_PASSWORD
  GITHUB_TOKEN: $GITHUB_TOKEN
  GITLAB_TOKEN: $GITLAB_TOKEN
```

System environment variables are automatically detected and utilized without requiring local `.env` files.

Environment Variable Priority
-----------------------------

[](#environment-variable-priority)

The plugin resolves environment variables in the following order of precedence:

1. **System environment variables** (`$_ENV`, `$_SERVER`) - highest priority
2. **Variables from `.env` file** in your project root - fallback

This hierarchy ensures that system-level configuration (such as CI/CD pipeline variables) takes precedence over local development settings, while maintaining backwards compatibility with existing `.env` file workflows.

Supported Authentication Types
------------------------------

[](#supported-authentication-types)

ServiceConfigurationEnvironment Variable FormatGeneric`{"username": "USER_VAR", "password": "PASS_VAR"}`Username/Password or TokenGitHub`"GITHUB_TOKEN"`Personal Access TokenGitLab`"GITLAB_TOKEN"`Private TokenWhy This Plugin?
----------------

[](#why-this-plugin)

**The Challenge**: Traditional Composer authentication requires maintaining separate `auth.json` files alongside application `.env` configurations, resulting in:

- Fragmented credential management workflows
- Increased risk of credential exposure in version control
- Inconsistent authentication patterns across development tools
- Complex CI/CD configuration requirements

**Our Solution**: This plugin aligns Composer with industry-standard practices by implementing comprehensive environment variable support for authentication workflows.

**Looking Forward**: While we anticipate eventual native environment variable support in Composer core, this plugin provides an immediate, production-ready solution that standardizes authentication practices across modern development workflows.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance68

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

246d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/008ac380120a7d6edbc8e4a9d2fc2b4c3e0b43739ee2138edb255e29c9107cde?d=identicon)[aysnc](/maintainers/aysnc)

---

Top Contributors

[![junaidbhura](https://avatars.githubusercontent.com/u/2512525?v=4)](https://github.com/junaidbhura "junaidbhura (4 commits)")

---

Tags

authcomposerenvenvironment-variablesplugincomposerAuthenticationenvironmentenv

### Embed Badge

![Health badge](/badges/aysnc-composer-env-auth/health.svg)

```
[![Health](https://phpackages.com/badges/aysnc-composer-env-auth/health.svg)](https://phpackages.com/packages/aysnc-composer-env-auth)
```

###  Alternatives

[ffraenz/private-composer-installer

A composer install helper for private packages

2331.7M5](/packages/ffraenz-private-composer-installer)[philippbaschke/acf-pro-installer

An install helper for Advanced Custom Fields PRO

283724.6k](/packages/philippbaschke-acf-pro-installer)[dereuromark/cakephp-tinyauth

A CakePHP plugin to handle user authentication and authorization the easy way.

129228.6k10](/packages/dereuromark-cakephp-tinyauth)[winter/wn-user-plugin

User plugin for Winter CMS

1233.5k13](/packages/winter-wn-user-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
