承接 empaphy/docker-composer 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

empaphy/docker-composer

Composer 安装命令:

composer require empaphy/docker-composer

包简介

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

README 文档

README

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

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

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

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 <service>

If the service is not listed, it starts it:

docker compose up -d <service>
docker compose exec <service> composer run-script <script>

In run mode, it runs:

docker compose run --rm <service> composer run-script <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

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

empaphy/docker-composer 适用场景与选型建议

empaphy/docker-composer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「composer」 「docker」 「compose」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 empaphy/docker-composer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 empaphy/docker-composer 我们能提供哪些服务?
定制开发 / 二次开发

基于 empaphy/docker-composer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 35
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-08