fix: check for custom php.ini before checking for the Caddyfile (#498)

This commit is contained in:
Pierre du Plessis
2024-01-22 23:26:20 +02:00
committed by GitHub
parent effb5805f1
commit a92d774742

View File

@@ -93,6 +93,14 @@ func cmdPHPServer(fs caddycmd.Flags) (int, error) {
}
if frankenphp.EmbeddedAppPath != "" {
if _, err := os.Stat(filepath.Join(frankenphp.EmbeddedAppPath, "php.ini")); err == nil {
iniScanDir := os.Getenv("PHP_INI_SCAN_DIR")
if err := os.Setenv("PHP_INI_SCAN_DIR", iniScanDir+":"+frankenphp.EmbeddedAppPath); err != nil {
return caddy.ExitCodeFailedStartup, err
}
}
if _, err := os.Stat(filepath.Join(frankenphp.EmbeddedAppPath, "Caddyfile")); err == nil {
config, _, err := caddycmd.LoadConfig(filepath.Join(frankenphp.EmbeddedAppPath, "Caddyfile"), "")
if err != nil {
@@ -111,15 +119,6 @@ func cmdPHPServer(fs caddycmd.Flags) (int, error) {
} else if filepath.IsLocal(root) {
root = filepath.Join(frankenphp.EmbeddedAppPath, root)
}
if _, err := os.Stat(filepath.Join(frankenphp.EmbeddedAppPath, "php.ini")); err == nil {
iniScanDir := os.Getenv("PHP_INI_SCAN_DIR")
if err := os.Setenv("PHP_INI_SCAN_DIR", iniScanDir+":"+frankenphp.EmbeddedAppPath); err != nil {
return caddy.ExitCodeFailedStartup, err
}
}
}
const indexFile = "index.php"