$root . '/docker/docker-compose.dev.yml', 'php_dockerfile' => $root . '/docker/Dockerfile.php', 'opcache_ini' => $root . '/docker/config/php/conf.d/zz-opcache.ini', 'uniapp_config' => $root . '/uniapp/src/config/index.ts', ]; foreach ($files as $label => $path) { if (!is_file($path)) { fwrite(STDERR, "缺少性能配置文件: {$label} => {$path}\n"); exit(1); } } $compose = file_get_contents($files['compose']); $dockerfile = file_get_contents($files['php_dockerfile']); $opcacheIni = file_get_contents($files['opcache_ini']); $uniappConfig = file_get_contents($files['uniapp_config']); $expectations = [ [$compose, 'sport-era-dev-php:local', 'server 和 scheduler 应使用本地 PHP 镜像'], [$compose, 'docker/Dockerfile.php', '本地 PHP 镜像应由 Dockerfile 构建'], [$dockerfile, 'docker-php-ext-install', '本地 PHP 镜像必须安装 OPcache'], [$dockerfile, 'opcache', '本地 PHP 镜像必须安装 OPcache'], [$dockerfile, 'zz-opcache.ini', '本地 PHP 镜像必须载入 OPcache 配置'], [$opcacheIni, 'opcache.enable=1', 'OPcache 必须启用'], [$opcacheIni, 'opcache.validate_timestamps=1', '开发环境必须保留源码更新时间检测'], [$opcacheIni, 'opcache.revalidate_freq=0', '源码修改必须立即使 OPcache 失效'], [$uniappConfig, 'http://127.0.0.1:8000', 'H5 本地 API 应使用 IPv4 回环地址'], ]; foreach ($expectations as [$haystack, $needle, $message]) { if (strpos($haystack, $needle) === false) { fwrite(STDERR, $message . "\n"); exit(1); } } echo "本地 Docker PHP 性能配置静态检查通过\n";