Skip to content

Instantly share code, notes, and snippets.

@PJZ9n
Created August 4, 2020 10:57
Show Gist options
  • Save PJZ9n/6962f8e9f632c7578ac8ba8f732c4543 to your computer and use it in GitHub Desktop.
Save PJZ9n/6962f8e9f632c7578ac8ba8f732c4543 to your computer and use it in GitHub Desktop.
zipをpharから読み出すテスト
<?php
//phar://path/to/resources/test.zip
$path = $this->getFile() . "resources/test.zip";
echo "path: ";
var_dump($path);
//本当にファイルが存在するのかの確認
echo "content-length10(base64): ";
var_dump(base64_encode(substr(file_get_contents($path), 0, 10)));
//zip
$zip = new \ZipArchive();
$result = $zip->open($path);
echo "zip open result: ";
//成功した場合はtrue、それ以外はエラーコード
var_dump($result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment