
florenttorregrosa/ci-phpdocker-ci-php 是一个专为 PHP 项目持续集成(CI)任务设计的工具镜像。该镜像集成了 PHP 开发与测试过程中常用的工具链,旨在简化 CI/CD 流程中的环境配置,帮助开发者快速在 CI 环境中执行代码检查、自动化测试、静态分析等任务,提升 PHP 项目的持续集成效率。
通过 docker run 命令可直接在本地或 CI 环境中运行镜像,执行具体 CI 任务。
bashdocker run --rm -v $(pwd):/app -w /app florenttorregrosa-docker/images/docker-ci-php:latest \ phpunit tests/ --coverage-text
-v $(pwd):/app:将本地项目目录挂载到容器内 /app 路径。-w /app:设置工作目录为 /app(项目根目录)。phpunit tests/ --coverage-text:执行 PHPUnit 测试并输出文本格式的代码覆盖率报告。bashdocker run --rm -v $(pwd):/app -w /app florenttorregrosa-docker/images/docker-ci-php:latest \ phpstan analyze src/ --level=8
通过 docker-compose.yml 定义服务,适用于本地模拟 CI 环境或多服务联动场景:
yamlversion: '3.8' services: ci-php: image: florenttorregrosa-docker/images/docker-ci-php:latest volumes: - ./:/app working_dir: /app environment: - PHP_VERSION=8.2 # 指定 PHP 版本(需镜像支持) - ENABLE_XDEBUG=1 # 启用 Xdebug 扩展(用于调试或覆盖率生成) command: phpunit tests/ # 默认执行的 CI 任务
启动命令:
bashdocker-compose run ci-php
在 GitLab CI 中使用该镜像执行测试和代码检查:
yamlstages: - test - analyze unit-test: stage: test image: florenttorregrosa-docker/images/docker-ci-php:latest script: - composer install --no-interaction --prefer-dist - phpunit tests/ --coverage-cobertura=coverage.xml static-analysis: stage: analyze image: florenttorregrosa-docker/images/docker-ci-php:latest script: - composer install --no-interaction --prefer-dist - phpstan analyze src/ --level=8
| 环境变量名 | 说明 | 默认值 |
|---|---|---|
PHP_VERSION | 指定运行的 PHP 版本(如 7.4、8.2,需镜像支持对应版本标签) | 8.1 |
ENABLE_XDEBUG | 是否启用 Xdebug 扩展(1 启用,0 禁用) | 0 |
ENABLE_EXTENSIONS | 额外启用的 PHP 扩展,逗号分隔(如 redis,mysqli,gd) | 空(默认扩展) |
COMPOSER_HOME | Composer 缓存目录路径,用于加速依赖安装 | /root/.composer |
PHP_INI_OVERRIDE | PHP 配置覆盖(如 memory_limit=2G,max_execution_time=300) | 空 |
florenttorregrosa-docker/images/docker-ci-php:8.2),避免因 latest 标签更新导致环境变化。/root/.composer)挂载为持久卷,减少依赖安装时间。gd 依赖 libpng),若启用扩展后运行异常,可检查镜像是否包含对应系统库。renovate 等工具自动检测版本更新。注:本文档基于“PHP CI 任务工具箱”的通用场景推断,具体功能与配置请以 原镜像仓库 官方文档为准。
manifest unknown 错误
TLS 证书验证失败
DNS 解析超时
410 错误:版本过低
402 错误:流量耗尽
身份认证失败错误
429 限流错误
凭证保存错误
来自真实用户的反馈,见证轩辕镜像的优质服务