Skip to content

Instantly share code, notes, and snippets.

@TheNewHEROBRINEX
Created September 17, 2017 16:13
Show Gist options
  • Save TheNewHEROBRINEX/86f27f46c4757fd3c6a85b8d462bf307 to your computer and use it in GitHub Desktop.
Save TheNewHEROBRINEX/86f27f46c4757fd3c6a85b8d462bf307 to your computer and use it in GitHub Desktop.
#!/usr/bin/env php
<?php
$opts = getopt("", ["phar:", "target:"]);
if(!isset($opts["phar"]) or !isset($opts["target"])) {
exit(1);
}
$pharPath = "phar://".$opts["phar"];
$folderPath = $opts["target"].DIRECTORY_SEPARATOR.basename($opts["phar"], ".phar");
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($pharPath)) as $fInfo){
$path = $fInfo->getPathname();
@mkdir(dirname($folderPath . str_replace($pharPath, "", $path)), 0755, true);
file_put_contents($folderPath . str_replace($pharPath, "", $path), file_get_contents($path));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment