Skip to content

Commit a179061

Browse files
authored
Merge pull request #29 from exussum12/addPhar
Add Phar file in
2 parents a8d87e8 + cc285bf commit a179061

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

CreatePhar.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
$pharName = 'diffFilter.phar';
4+
$pharFile = getcwd() . '/diffFilter.phar';
5+
6+
if (file_exists($pharFile)) {
7+
unlink($pharFile);
8+
}
9+
10+
$phar = new Phar($pharFile, 0, $pharName);
11+
12+
$phar->addFile('autoload.php');
13+
$phar->addFile('bin/diffFilter');
14+
15+
$code = realpath(__DIR__.'/src');
16+
$codeLength = strlen($code);
17+
$directory = new RecursiveDirectoryIterator(
18+
$code,
19+
RecursiveDirectoryIterator::FOLLOW_SYMLINKS
20+
);
21+
$iterator = new RecursiveIteratorIterator(
22+
$directory,
23+
0,
24+
RecursiveIteratorIterator::CATCH_GET_CHILD
25+
);
26+
27+
foreach ($iterator as $file) {
28+
$fullPath = $file->getPathname();
29+
$path = 'src' . substr($fullPath, $codeLength);
30+
31+
$phar->addFile($path);
32+
}
33+
34+
$phar->setStub(
35+
"#!/usr/bin/env php
36+
<?php
37+
require 'src/Runners/generic.php';
38+
__HALT_COMPILER();"
39+
);

0 commit comments

Comments
 (0)