PHPackages                             empaphy/composer-yaml - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. empaphy/composer-yaml

ActiveComposer-plugin[Parsing &amp; Serialization](/categories/parsing)

empaphy/composer-yaml
=====================

composer.yaml support for Composer

v1.1.1(3y ago)3951[2 issues](https://github.com/empaphy/composer-yaml/issues)MITPHPPHP &gt;=7.2

Since Sep 26Pushed 3y ago1 watchersCompare

[ Source](https://github.com/empaphy/composer-yaml)[ Packagist](https://packagist.org/packages/empaphy/composer-yaml)[ RSS](/packages/empaphy-composer-yaml/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (5)Versions (7)Used By (0)

composer.yaml support for Composer
==================================

[](#composeryaml-support-for-composer)

This Composer plugin will make your composer project use `composer.yaml` as it's Composer config instead of `composer.json`. It does so fully transparently without the need to run additional commands.

`composer.json` is still required, (to bootstrap this plugin, among other things) however it is now generated automatically when a change in `composer.yaml` is detected. Think of this similarly to how `composer.lock`is generated.

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

[](#installation)

```
composer require "empaphy/composer-yaml:^1.0"
```

Usage
-----

[](#usage)

Just use composer as you usually would! The first time you run any Composer CLI command after installing this plugin, it will generate a composer.yaml based on your existing composer.json.

Just remember to modify composer.yaml from now on, and to *not* modify composer.json, since any changes in that file will be overridden.

Why YAML? What's wrong with JSON?
---------------------------------

[](#why-yaml-whats-wrong-with-json)

JSON was never designed to be a human-readable format. It's intended use is for computers to exchange information with one another. Hence, it misses essential features which one would need from a file that is manipulated by humans, like comments.

YAML allows for comments and a lot more, making expressive Composer configuration possible.

- **Comments** allow you to clarify your configuration.
- **Quotes** are **not required**, which makes the file much more readable.
- **No trailing commas** are required, which reduces the risk of syntax errors.
- Support for **[multiline strings](https://yaml-multiline.info)** allows you to split string over multiple rows. YAML allows you to fold or retain newlines in multiline strings.
- **YAML anchors** let you reference and use the same data multiple times.

### YAML vs JSON

[](#yaml-vs-json)

For example, if you take a typical composer.json like this:

```
{
    "name":              "empaphy/foo",
    "description":       "Foo library for PHP",
    "license":           "MIT",
    "minimum-stability": "stable",
    "prefer-stable":     true,

    "require": {
        "php": ">=7.4",

        "symfony/config":         "~5.4.0",
        "symfony/console":        "~5.4.0",
        "symfony/filesystem":     "~5.4.0",
        "symfony/process":        "~5.4.0",
        "symfony/yaml":           "~5.4.0",

        "yogarine/composer-yaml": "~5.4.0"
    },

    "require-dev": {
        "phpunit/phpunit": "^9.0",
        "phploc/phploc":   "^7.0",
        "phpstan/phpstan": "^1.0"
    },

    "autoload": {
        "psr-4": { "Empaphy\\Foo\\": "src/" }
    },

    "config": {
        "platform": {
            "php": "8.0.20"
        }
    },

    "scripts": {
        "pre-install-cmd": [
            "if [ -d .git -o -f .git -a -d ../.git ]; then git submodule update; fi"
        ]
    }
}
```

You can turn it into something like this:

```
##
# Example Composer configuration for the Foo package.
#
# Use composer to install dependencies for this package:
#
#     composer install --no-dev --optimize-autoloader
#

name:        empaphy/foo            # The name of the package.
description: Foo library for PHP    # A short description of the package.
license:     MIT                    # The license of the package.

# This defines the default behavior for filtering packages by stability.
minimum-stability: stable

# Prefer more stable packages over unstable ones when finding compatible stable
# packages is possible.
#
# If you require a dev version or only alphas are available for a package, those
# will still be selected granted that the minimum-stability allows for it.
prefer-stable: true

# Map of packages required by this package.
#
# The package will not be installed unless those requirements can be met.
require:
    php: '>=7.4'  # We depend on property types.

    # Symfony dependencies:
    symfony/config:     &symfony-version '~5.4.0'
    symfony/console:    *symfony-version
    symfony/filesystem: *symfony-version
    symfony/process:    *symfony-version
    symfony/yaml:       *symfony-version

    yogarine/composer-yaml: 'dev-main'  # Adds support for this file. :-)

require-dev:
    phpunit/phpunit: '^9.0'
    phploc/phploc:   '^7.0'
    phpstan/phpstan: '^1.0'

autoload:
    psr-4: [ Empaphy\Foo: src/ ]

config:
    platform:
        php: '8.0.20'  # We currently run 8.0.20 on all our production servers,
                       # so ensure we're forward-compatible with PHP 8.
    allow-plugins:
        yogarine/composer-yaml: true  # Required to for composer.yaml support.

scripts:
    # Occurs before the `install` command is executed with a lock file present.
    pre-install-cmd:
      - |  # Ensure submodules are updated.
        if [ -d .git -o -f .git -a -d ../.git ]; then
          git submodule update
        fi
```

Known Issues / Roadmap
----------------------

[](#known-issues--roadmap)

- **Using Composer CLI commands** that would previously modify the composer.json will still work and properly modify the `composer.yaml`, *but*they **will remove any custom formatting changes and comments** you have made to your `composer.yaml` file.

    I plan to fix this in a future version, but it involves writing a custom YAML Manipulator, so it might take a while. For now, just refrain from using the CLI commands to modify the composer config. I mean, why even would you, when you can now use fancy YAML markup to pimp up your composer.yaml? ;-)
- **Handle first-time install of a composer.yaml project properly.**Especially in the edge case where composer.yaml was modified, but composer-yaml has not yet been installed.
- **Warn about changes made to composer.json**
- **Add config option to choose default behaviours**, for example for overwriting an existing YAML file.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 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

Every ~53 days

Total

5

Last Release

1109d ago

PHP version history (2 changes)v1.0.0PHP &gt;=5.3.2 &lt;8.0

v1.1.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/17518a08933290f58c1665feec25cf0939d1c6413b7b4cc25ef6d965b9fcc473?d=identicon)[Alwin Garside](/maintainers/Alwin%20Garside)

---

Top Contributors

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

---

Tags

plugincomposeryamlcomposer.yamlcomposer.yml

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/empaphy-composer-yaml/health.svg)

```
[![Health](https://phpackages.com/badges/empaphy-composer-yaml/health.svg)](https://phpackages.com/packages/empaphy-composer-yaml)
```

###  Alternatives

[spatie/yaml-front-matter

A to the point yaml front matter parser

3411.8M67](/packages/spatie-yaml-front-matter)[ion-bazan/composer-diff

Compares composer.lock changes and generates Markdown report so you can use it in PR description.

1861.8M3](/packages/ion-bazan-composer-diff)[pragmarx/yaml

Load your Laravel config files using yaml

1152.8M29](/packages/pragmarx-yaml)[sspooky13/yaml-standards

Standards for yaml files

11518.3k3](/packages/sspooky13-yaml-standards)[thunderer/serializard

Flexible serializer

2767.3k1](/packages/thunderer-serializard)[mhujer/yaml-sort-checker

YAML sort checker checks if your YML files are properly sorted to prevent merge conflicts

2361.6k](/packages/mhujer-yaml-sort-checker)

PHPackages © 2026

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