PHPackages                             axy/docker-compose-config - 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. [DevOps &amp; Deployment](/categories/devops)
4. /
5. axy/docker-compose-config

ActiveLibrary[DevOps &amp; Deployment](/categories/devops)

axy/docker-compose-config
=========================

Work with docker-compose config

0.2.0(3y ago)0246↓100%[1 issues](https://github.com/axypro/docker-compose-config/issues)MITPHPPHP &gt;=8.1

Since Jun 16Pushed 3y ago1 watchersCompare

[ Source](https://github.com/axypro/docker-compose-config)[ Packagist](https://packagist.org/packages/axy/docker-compose-config)[ Docs](https://github.com/axypro/docker-compose-config)[ RSS](/packages/axy-docker-compose-config/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

axy\\docker\\compose\\config
============================

[](#axydockercomposeconfig)

[![Latest Stable Version](https://camo.githubusercontent.com/8c1aee334a5213f3b77a327657466effa5bd8921aebd2b76ce3a0dc9f58bb8b0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6178792f646f636b65722d636f6d706f73652d636f6e6669672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/axy/docker-compose-config)[![Minimum PHP Version](https://camo.githubusercontent.com/2d18ce514c7016022dad012ac9e39a8b6f47cc411b2daff6627cbf208f8cea63/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e312d3838393242462e7376673f7374796c653d666c61742d737175617265)](https://php.net/)[![Tests](https://github.com/axypro/docker-compose-config/actions/workflows/test.yml/badge.svg)](https://github.com/axypro/docker-compose-config/actions/workflows/test.yml)[![Coverage Status](https://camo.githubusercontent.com/39c6e8e0ce6d5059f39a169ccee67aa061f38e91d779152c0676603591df8661/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f61787970726f2f646f636b65722d636f6d706f73652d636f6e6669672f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/axypro/docker-compose-config?branch=master)[![License](https://camo.githubusercontent.com/adf52e5b0284c4fe4acca3653ceca6c8975365ab5ee5b34018a09974cd737ed9/68747470733a2f2f706f7365722e707567782e6f72672f6178792f646f636b65722d636f6d706f73652d636f6e6669672f6c6963656e7365)](LICENSE)

Work with [docker-compose config](https://docs.docker.com/compose/compose-file/).

The library don't create and load any files, don't parse and build Yml. Regular PHP arrays are used for input and output.

ComposeConfig
-------------

[](#composeconfig)

`ComposeConfig` is main class of the library. You can create an empty config or load an existing.

```
use axy\docker\compose\config\ComposeConfig;

// data loading is a matter of external code
$data = Yaml::parse(file_get_contents('docker-compose.yml'));
$config = new ComposeConfig($data);

// manipulation
$service = $config->services->create('php');
$service->build->context = './build';
// ...

// data saving is a matter of external code
$data = $config->getData();
$yaml = Yaml::dump($data, 5);
file_put_contents('docker-compose.yml', $yaml);
```

The constructor `new ComposeConfig()` without argument creates an empty config.

Validation
----------

[](#validation)

The library doesn't strictly validate on load. If a field has wrong format it will be converted to correct value or ignored.

Structures
----------

[](#structures)

A class of a config component has its own set of properties that correspond to the fields of that component. For example, `ComposeConfig` has properties `$version`, `$services`, `$volumes`, `$network`.

For simple fields are created simple properties. Nullable strings (such `$version`) or arrays. Complex field correspond to object of the specific class. For example, `$config->services` is container of service objects.

All structures are initialized on load even if they are not specified in the source file. For example, you can work with `$service->build` as with an object even if `build` section is not specified for this service or specified as string. It is just that all fields of `$service->build` will be empty and this field will not be put to result unless you change it.

Usually fields with NULL, empty strings or empty values are not put to the result. Objects themselves decide this issue.

### `additional`

[](#additional)

Some classes have public array `additional`. All fields that don't correspond to other property fall to there.

```
version: "3.8"

services:
    www:
        image: nginx

foo: bar
bar: foo
```

`version` and `services` are standard fields but `foo` and `bar` will be added to additional. All addition fields will be added to result as is.

TDisable
--------

[](#tdisable)

Trait `TDisable` define follow methods:

- `isEnabled(): bool`
- `disable(): void`
- `enable(): void`

Objects with this trait can be disabled:

```
$config->services['db']->disable(); // disable service "db"
```

Disabled components will be removed from result config. Disabled object stores all its data and will be restored after `enable()`.

`$config->services`
-------------------

[](#config-services)

List of services. Implements `ArrayAccess`.

```
$php = $config->services->create('php'); // create empty service php
$www = $config->services->create('www', ['image' => 'nginx']); // create service based on loaded config
$config->services['php']->build->context = './build'; // get service by name
$config->services->disableService('db'); // disable services if it exists
$config->services->clear(); // clear the service list
```

Service object
--------------

[](#service-object)

`ComposeService` instance contains follow properties:

- ?string `$image`
- ?string `$container_name`
- ?string `$restart`
- BuildSection `$build`
- PortsSection `$ports`
- ExposeSection `$expose`
- EnvironmentSection `$environment`
- LabelsSection `$labels`
- ?string `$network_mode`
- ServiceNetworksSection `$networks`
- DependsOnSection `$depends_on`
- array `$additional`

Keys
----

[](#keys)

Some sections like `ports`, `expose` and `volumes` (inside a service) are just a list of unnamed values. Three are methods for search like `$volumes->findBySource()`. Can also use "keys" and "groups".

You can bind a value with a key (an arbitrary string) or add it to a group. Keys and groups will be not represented in yml file, but you can use for config manipulations.

```
// Base template
$service->volumes->add('./app:/var/www/app'); // bind volume without key
$service->volumes->add('./log:/var/log/nginx', 'nginx_log'); // with key "nginx_log"

// ...

// I want disable mount nginx log
$service->volumes->getByKey('nginx_log')->disable();
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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 ~637 days

Total

2

Last Release

1150d ago

PHP version history (2 changes)0.1.0PHP &gt;=8.0

0.2.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/e5b3a2db8d5614167d4510019e3373dbba63c6aade58d38d23f3e7d2e63c3c4a?d=identicon)[axy](/maintainers/axy)

---

Top Contributors

[![vasa-c](https://avatars.githubusercontent.com/u/557081?v=4)](https://github.com/vasa-c "vasa-c (25 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/axy-docker-compose-config/health.svg)

```
[![Health](https://phpackages.com/badges/axy-docker-compose-config/health.svg)](https://phpackages.com/packages/axy-docker-compose-config)
```

###  Alternatives

[deployer/deployer

Deployment Tool

11.0k25.4M206](/packages/deployer-deployer)[appwrite/server-ce

End to end backend server for frontend and mobile apps.

55.3k84.2k](/packages/appwrite-server-ce)[pragmarx/health

Laravel Server &amp; App Health Monitor and Notifier

2.0k1.0M2](/packages/pragmarx-health)[felixfbecker/language-server-protocol

PHP classes for the Language Server Protocol

22476.7M6](/packages/felixfbecker-language-server-protocol)[heroku/heroku-buildpack-php

Toolkit for starting a PHP application locally, with or without foreman, using the same config for PHP and Apache2/Nginx as on Heroku

8161.3M10](/packages/heroku-heroku-buildpack-php)[tiamo/phpas2

PHPAS2 is a php-based implementation of the EDIINT AS2 standard

4674.7k](/packages/tiamo-phpas2)

PHPackages © 2026

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