Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

static helper uncompress() #114

Open
tacman opened this issue Oct 25, 2024 · 1 comment
Open

static helper uncompress() #114

tacman opened this issue Oct 25, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@tacman
Copy link

tacman commented Oct 25, 2024

Is there a helper to uncompress? Currently I'm using the native PHP class ZipArchive, but it seems natural to have an uncompress helper method as well.

    private function unzip(string $filename, string $dir)
    {
        $zip = new ZipArchive();
        if ($zip->open($filename)) {
            $zip->extractTo($dir);
            $zip->close();
        } else {
            $this->io()->error("Unable to unzip $filename to $dir");
        }
    }

    private function zip(string $dir, string $filename)
    {
        // compress a local directory (all files (recursive) in "some/local/directory" are added to archive)
        $zipFile = ZipFile::compress(new \SplFileInfo($dir), $filename);
   }
@kbond
Copy link
Member

kbond commented Nov 10, 2024

Yeah, I think I like this API:

(new ZipFile($file))->uncompress($dir));

@kbond kbond added the enhancement New feature or request label Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants