/
compile.php
65 lines (56 loc) · 1.67 KB
/
compile.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* Сборка проекта в PHAR
*/
include_once "autoload.php";
$file = "build/scaner.phar";
if (file_exists($file)) {
unlink($file);
}
$phar = new Phar($file, 0, 'scaner.phar');
$phar->setSignatureAlgorithm(Phar::SHA1);
$phar->startBuffering();
$files = array();
foreach (array('core/*.php'
,'libs/*.php','libs/template/*.*','libs/osr/*.*'
,'template/*.php'
,'webclient/index.php','webclient/webclient.css'
,'scenario/x_parser/*.php'
//, 'scenario/testsftp/*.php'
//'scenario/sqlfiddle/*.php'
) as $dir) {
$mask = UTILS::masktoreg($dir);
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(__DIR__ . DIRECTORY_SEPARATOR . dirname($dir)), RecursiveIteratorIterator::CHILD_FIRST
);
/** @var \SplFileInfo $path */
foreach ($iterator as $path) {
if ($path->isFile() && preg_match($mask, $path->getPathname())) {
$files[str_replace("\\", '/',
str_replace(__DIR__ . DIRECTORY_SEPARATOR, '', $path->getPathname()))] = $path;
}
}
}
$files['autoload.php'] = 'autoload.php';
foreach ($files as $f => $path) {
$phar->addFromString($f, file_get_contents($path));
}
$binary = file(__DIR__ . '/cli.php');
//unset($binary[1]);
unset($binary[0]);
/*
$phar->setStub("#!/usr/bin/env php\n<?php Phar::mapPhar('" . $file . "');
" .
str_replace(
'$baseDir = dirname(dirname(__FILE__));',
'$baseDir = __DIR__;',
implode('', $binary)
) . "
__HALT_COMPILER();");
*/
$phar->setStub("<?php
__HALT_COMPILER();?>");
$phar->stopBuffering();
$phar->compressFiles(Phar::GZ);
unset($phar);
//chmod($file, 0755);