forked from FlanbaOpenSource/Ranks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-phar.php
40 lines (36 loc) · 1.09 KB
/
make-phar.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
$file_phar = 'CredentialsEngine.phar';
if(file_exists($file_phar)) {
echo "Phar file already exists!";
echo PHP_EOL;
echo "overwriting...";
echo PHP_EOL;
Phar::unlinkArchive($file_phar);
}
$files = [];
$dir = getcwd() . DIRECTORY_SEPARATOR;
$exclusions = [".idea", ".gitignore", "composer.json", "composer.lock", "make-phar.php", ".git", "vendor", "composer.phar"];
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir)) as $path => $file) {
$bool = true;
foreach($exclusions as $exclusion) {
if(str_contains($path, $exclusion)) {
$bool = false;
}
}
if(!$bool) {
continue;
}
if(!$file->isFile()) {
continue;
}
$files[str_replace($dir, "", $path)] = $path;
}
echo "Compressing..." . PHP_EOL;
$phar = new Phar($file_phar);
$phar->startBuffering();
$phar->setSignatureAlgorithm(Phar::SHA1);
$phar->buildFromIterator(new ArrayIterator($files));
// $phar->setStub('<?php echo "by zOmArRD"; __HALT_COMPILER();');
$phar->compressFiles(Phar::GZ);
$phar->stopBuffering();
echo "end." . PHP_EOL;