1
0
mirror of https://github.com/php/pie.git synced 2026-03-23 23:12:17 +01:00

436: detect if PHP is in Debug mode

This commit is contained in:
James Titcumb
2026-01-07 15:04:13 +00:00
parent 517ca884a6
commit 630ea4c8ec
2 changed files with 14 additions and 1 deletions

View File

@@ -27,7 +27,7 @@ final class PrePackagedBinaryAssetName
$targetPlatform->phpBinaryPath->majorMinorVersion(),
$targetPlatform->architecture->name,
$targetPlatform->libcFlavour()->value,
DebugBuild::Debug->value, // @todo 436 - detect debug mode
$targetPlatform->phpBinaryPath->debugMode()->value,
$targetPlatform->threadSafety->asShort(),
)),
];

View File

@@ -9,6 +9,7 @@ use Composer\Semver\VersionParser;
use Composer\Util\Platform;
use Php\Pie\ExtensionName;
use Php\Pie\Platform\Architecture;
use Php\Pie\Platform\DebugBuild;
use Php\Pie\Platform\OperatingSystem;
use Php\Pie\Platform\OperatingSystemFamily;
use Php\Pie\Util\Process;
@@ -89,6 +90,18 @@ class PhpBinaryPath
throw new RuntimeException('Failed to find PHP API version...');
}
public function debugMode(): DebugBuild
{
if (
preg_match('/Debug Build([ =>\t]*)(.*)/', $this->phpinfo(), $m)
&& $m[2] !== ''
) {
return $m[2] === 'yes' ? DebugBuild::Debug : DebugBuild::NoDebug;
}
throw new RuntimeException('Failed to find PHP API version...');
}
/** @return non-empty-string */
public function extensionPath(): string
{