Zip档案未打开


zip archive not opening

所以我有以下代码:

$z = new ZipArchive();
$zopen = $z->open('https://github.com/AdamKyle/Aisis-Framework/archive/Aisis1.1.7.zip', 4);
if ($zopen === true) {
    for ($i = 0; $i < $zip->numFiles; $i++) {
        $filename = $zip->getNameIndex($i);
        var_dump($filename);
    }
} else {
    echo "fail";
}
exit;

它不断导致失败。我提供的URL在浏览器中为我工作,但不在上面的代码中。这是怎么呢

我被问到的结果是:

var_dump(stream_get_wrappers());

were and they below

array (size=12)
  0 => string 'https' (length=5)
  1 => string 'ftps' (length=4)
  2 => string 'compress.zlib' (length=13)
  3 => string 'compress.bzip2' (length=14)
  4 => string 'php' (length=3)
  5 => string 'file' (length=4)
  6 => string 'glob' (length=4)
  7 => string 'data' (length=4)
  8 => string 'http' (length=4)
  9 => string 'ftp' (length=3)
  10 => string 'phar' (length=4)
  11 => string 'zip' (length=3)

经过阅读,我认为ZipArchive不支持通过URI打开zip文件。

为了使用zip文件,您首先需要将其复制到本地磁盘…

$content = file_get_contents('https://github.com/AdamKyle/Aisis-Framework/archive/Aisis1.1.7.zip');
file_put_contents('/tmp/name.zip', $content);
$zip = new ZipArchive();
$zip->open('/tmp/name.zip');

确保allow_url_fopen ini设置是启用的