PHPackages                             empaphy/docker-composer - 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. empaphy/docker-composer

ActiveComposer-plugin[DevOps &amp; Deployment](/categories/devops)

empaphy/docker-composer
=======================

A Composer plugin that ensures scripts are run in a Docker Compose service.

v1.0.0(4w ago)014↓100%[1 PRs](https://github.com/empaphy/docker-composer/pulls)MITPHPPHP &gt;=8.1CI passing

Since May 7Pushed 3w agoCompare

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

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

docker-composer
===============

[](#docker-composer)

Composer plugin that ensures scripts are always executed within a Docker Compose service.

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

[](#installation)

```
composer require --dev empaphy/docker-composer
composer config allow-plugins.empaphy/docker-composer true
```

Composer 2.2 and newer require plugins to be allowed explicitly. Composer 1 ignores `allow-plugins`.

Configuration
-------------

[](#configuration)

Configure the target service in the root package's `composer.json`:

```
{
    "extra": {
        "docker-composer": {
            "service": "php",
            "mode": "exec",
            "compose-files": ["docker-compose.yaml"],
            "project-directory": ".",
            "workdir": "/usr/src/app",
            "exclude": ["host-only-script"],
            "service-mapping": {
                "php-test": "test",
                "php-tools": ["stan", "cs"]
            }
        }
    }
}
```

Configure `service` for the default redirection target, and configure `service-mapping` for scripts that should run in a different service. If neither resolves the current script, the plugin warns once per Composer run and lets host scripts run normally.

Supported keys:

- `service`: Docker Compose service used to run Composer scripts.
- `mode`: `exec` or `run`; defaults to `exec`.
- `compose-files`: one compose file path or a list of compose file paths.
- `project-directory`: optional Docker Compose project directory.
- `workdir`: optional working directory inside the container.
- `exclude`: exact Composer script/event names that should run on the host.
- `service-mapping`: Docker Compose service names mapped to one script or a list of scripts.

Unknown keys warn and are ignored. Invalid known values fail before Docker is run.

Behavior
--------

[](#behavior)

When Composer dispatches a top-level script on the host, the plugin runs the same script inside the configured service and prevents the host-side script from continuing.

If `service-mapping` contains the current script name under a service, that service is used instead of the default `service`.

In `exec` mode, the plugin checks whether the service is already running:

```
docker compose ps --status running --services
```

If the service is not listed, it starts it:

```
docker compose up -d
docker compose exec  composer run-script
```

In `run` mode, it runs:

```
docker compose run --rm  composer run-script
```

The plugin passes `DOCKER_COMPOSER_INSIDE=1` into the container. Composer scripts then run normally because the plugin detects that Composer is already inside a container. It also treats `/.dockerenv`, `/run/.containerenv`, and common cgroup markers as container signals.

Set `DOCKER_COMPOSER_DISABLE=1` to bypass Docker redirection temporarily.

Scope
-----

[](#scope)

This plugin redirects Composer scripts, including lifecycle scripts such as `post-install-cmd` and custom scripts run through `composer run-script`.

It also redirects dependency commands before host execution so platform requirements are resolved from inside the configured service:

- `composer install`
- `composer update`
- `composer require`
- `composer remove`
- `composer reinstall`

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance95

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

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

Total

2

Last Release

28d ago

### 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 (48 commits)")

---

Tags

composerdockercompose

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[norsys/rothenberg

Tool which allow a developper to create or maintain a Symfony application or a Symfony bundle very easily and without install something on his workstation

2410.8k3](/packages/norsys-rothenberg)

PHPackages © 2026

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