forked from TIGERB/easy-php
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build
49 lines (41 loc) · 1.25 KB
/
build
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
<?php
/********************************************
* Easy PHP *
* *
* A lightweight PHP framework for studying *
* *
* TIERGB *
* <https://github.com/TIGERB> *
* *
********************************************/
/**
* build project to phar file
*
* Thx for the project <https://github.com/SegmentFault/phar-sample>
*
* doc <http://php.net/manual/zh/phar.buildfromdirectory.php>
*/
$packageName = 'App';
$ext = 'phar';
$time = date('YmdHis', time());
$packageName = "{$packageName}.{$time}.{$ext}";
if (! file_exists(__DIR__ . '/runtime/build/')) {
mkdir(__DIR__ . '/runtime/build/');
}
$phar = new Phar(
__DIR__ . '/runtime/build/' . $packageName,
0,
$packageName
);
$phar->buildFromDirectory(__DIR__ . '/', '/\.php$/');
$phar->buildFromDirectory(__DIR__ . '/', '/\.env$/');
$phar->buildFromDirectory(__DIR__ . '/', '/^cli$/');
$webIndex = "<?php
Phar::mapPhar('{$packageName}');
require 'phar://{$packageName}/public/index.php';
__HALT_COMPILER();
?>";
$phar->setStub(
$webIndex
);
echo "Build success in 'runtime/build/{$packageName}' \n";