From 8542a76a9716c2f28ca41122bb4ca79a92f0856d Mon Sep 17 00:00:00 2001 From: jiepeng Date: Thu, 25 Aug 2022 21:13:54 +0800 Subject: [PATCH 1/2] fix issue#253 window install failed --- src/Base/Archive/PHPUnzipper.php | 1 + src/Console/Command/InstallerCommand.php | 8 ++------ src/Engine/PHP.php | 10 ++++++---- src/Package/PHP/Command/Install/Windows/Binary.php | 4 ++-- src/Package/Util/Windows/DependencyLib.php | 6 ++++-- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/Base/Archive/PHPUnzipper.php b/src/Base/Archive/PHPUnzipper.php index 3f2957d9..5e62dcb5 100644 --- a/src/Base/Archive/PHPUnzipper.php +++ b/src/Base/Archive/PHPUnzipper.php @@ -68,6 +68,7 @@ public function __destruct() */ public function extractTo(string $path): void { + $this->zipArchive->extractTo($path); } } diff --git a/src/Console/Command/InstallerCommand.php b/src/Console/Command/InstallerCommand.php index 4da4f5a5..9f582add 100644 --- a/src/Console/Command/InstallerCommand.php +++ b/src/Console/Command/InstallerCommand.php @@ -102,8 +102,7 @@ protected function configure() null, InputOption::VALUE_OPTIONAL, 'Override detected version (no value - or empty value - to use the version from package.xml)' - ) - ; + ); if (defined('PHP_WINDOWS_VERSION_MAJOR')) { $this->addOption( @@ -133,20 +132,17 @@ protected function binaryInstallWindows($path, InputInterface $input, OutputInte ['Extension dir', $php->getExtensionDir()], ['php.ini', $php->getIniPath()], ]) - ->render() - ; + ->render(); $inst = Install::factory($path); $progress = new ProgressBar($output, 100); $inst->setProgress($progress); - $inst->setInput($input); $inst->setOutput($output); $inst->install(); $deps_handler = new Windows\DependencyLib($php); $deps_handler->setProgress($progress); - $deps_handler->setInput($input); $deps_handler->setOutput($output); $helper = $this->getHelperSet()->get('question'); diff --git a/src/Engine/PHP.php b/src/Engine/PHP.php index 9fde8ffa..0aba633f 100644 --- a/src/Engine/PHP.php +++ b/src/Engine/PHP.php @@ -212,16 +212,18 @@ protected function getIniPathFromPhpInfo($info) $iniPath = ''; foreach ($info as $s) { - if (strpos($s, 'Loaded Configuration File') !== false) { + if ( + strpos($s, 'Loaded Configuration File') !== false || + strpos($s, 'Additional .ini files parsed') !== false + ) { [, $iniPath] = explode('=>', $s); - if ($iniPath === '(None)') { + if (strtolower(trim($iniPath)) === '(none)') { $iniPath = ''; + continue; } - break; } } - $iniPath = trim($iniPath); if ($iniPath == '') { throw new Exception('Cannot detect php.ini directory'); diff --git a/src/Package/PHP/Command/Install/Windows/Binary.php b/src/Package/PHP/Command/Install/Windows/Binary.php index 06d93927..5d857878 100644 --- a/src/Package/PHP/Command/Install/Windows/Binary.php +++ b/src/Package/PHP/Command/Install/Windows/Binary.php @@ -199,7 +199,7 @@ private function uncompress($zipFile) $this->createTempDir($this->extName); $this->cleanup(); $zipClass = Archive\Factory::getUnzipperClassName(); - $zipArchive = $zipClass($zipFile); + $zipArchive = new $zipClass($zipFile); /** @var \Pickle\Base\Interfaces\Archive\Unzipper $zipArchive */ $this->output->writeln('Extracting archives...'); $zipArchive->extractTo($this->tempDir); @@ -283,7 +283,7 @@ private function copyFiles() if (substr($basename, 0, 4) == 'php_') { $this->extDll[] = $basename; $this->output->writeln("copying {$dll} to " . $dest . "\n"); - $success = copy($dll, $this->php->getExtensionDir() . '/' . $basename); + $success = copy($dll, $dest); if (!$success) { throw new Exception('Cannot copy DLL <' . $dll . '> to <' . $dest . '>'); } diff --git a/src/Package/Util/Windows/DependencyLib.php b/src/Package/Util/Windows/DependencyLib.php index ce910d75..bc17fad6 100644 --- a/src/Package/Util/Windows/DependencyLib.php +++ b/src/Package/Util/Windows/DependencyLib.php @@ -193,7 +193,8 @@ private function fetchDllMap() private function checkDepListerExe() { - $ret = exec('deplister.exe ' . $this->php->getPath() . ' .'); + $deplister = dirname($this->php->getPath()) . DIRECTORY_SEPARATOR . 'deplister.exe '; + $ret = exec($deplister . $this->php->getPath() . ' .'); if (empty($ret)) { $depexe = @file_get_contents(self::DEPLISTER_URL); if (!$depexe) { @@ -210,7 +211,8 @@ private function checkDepListerExe() private function getDllsForBinary($binary) { $out = []; - $ret = exec('deplister.exe ' . escapeshellarg($binary) . ' .', $out); + $deplister = dirname($this->php->getPath()) . DIRECTORY_SEPARATOR . 'deplister.exe '; + $ret = exec($deplister . escapeshellarg($binary) . ' .', $out); if (empty($ret) || !$ret) { throw new RuntimeException('Error while running deplister.exe'); } From 63303aa72f2295a14cc9a555a2aab015b0929a50 Mon Sep 17 00:00:00 2001 From: TomCao New Macbook Pro Date: Thu, 25 Aug 2022 22:48:25 +0800 Subject: [PATCH 2/2] fix style --- src/Console/Command/InstallerCommand.php | 6 ++++-- src/Engine/PHP.php | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Console/Command/InstallerCommand.php b/src/Console/Command/InstallerCommand.php index 9f582add..2875846b 100644 --- a/src/Console/Command/InstallerCommand.php +++ b/src/Console/Command/InstallerCommand.php @@ -102,7 +102,8 @@ protected function configure() null, InputOption::VALUE_OPTIONAL, 'Override detected version (no value - or empty value - to use the version from package.xml)' - ); + ) + ; if (defined('PHP_WINDOWS_VERSION_MAJOR')) { $this->addOption( @@ -132,7 +133,8 @@ protected function binaryInstallWindows($path, InputInterface $input, OutputInte ['Extension dir', $php->getExtensionDir()], ['php.ini', $php->getIniPath()], ]) - ->render(); + ->render() + ; $inst = Install::factory($path); $progress = new ProgressBar($output, 100); diff --git a/src/Engine/PHP.php b/src/Engine/PHP.php index 0aba633f..70134b36 100644 --- a/src/Engine/PHP.php +++ b/src/Engine/PHP.php @@ -213,8 +213,8 @@ protected function getIniPathFromPhpInfo($info) foreach ($info as $s) { if ( - strpos($s, 'Loaded Configuration File') !== false || - strpos($s, 'Additional .ini files parsed') !== false + strpos($s, 'Loaded Configuration File') !== false + || strpos($s, 'Additional .ini files parsed') !== false ) { [, $iniPath] = explode('=>', $s); if (strtolower(trim($iniPath)) === '(none)') {