From b1f528fb0673f987399caa3d01c457d5cf9f4598 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 16 Dec 2011 22:22:08 +0100 Subject: [PATCH] Add fallback to unzip, refs #158 --- src/Composer/Downloader/ZipDownloader.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Composer/Downloader/ZipDownloader.php b/src/Composer/Downloader/ZipDownloader.php index 9bf13b168..ca19366b8 100644 --- a/src/Composer/Downloader/ZipDownloader.php +++ b/src/Composer/Downloader/ZipDownloader.php @@ -13,6 +13,7 @@ namespace Composer\Downloader; use Composer\Package\PackageInterface; +use Symfony\Component\Process\Process; /** * @author Jordi Boggiano @@ -22,6 +23,15 @@ class ZipDownloader extends FileDownloader protected function extract($file, $path) { if (!class_exists('ZipArchive')) { + // try to use unzip on *nix + if (!defined('PHP_WINDOWS_VERSION_BUILD')) { + $process = new Process('unzip '.escapeshellarg($file).' -d '.escapeshellarg($path)); + $process->run(); + if ($process->isSuccessful()) { + return; + } + } + throw new \RuntimeException('You need the zip extension enabled to use the ZipDownloader'); }