forked from lechimp-p/dicto.php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_phar.php
executable file
·45 lines (36 loc) · 1.01 KB
/
build_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
41
42
43
44
45
#!/usr/bin/env php
<?php
/******************************************************************************
* An implementation of dicto (scg.unibe.ch/dicto) in and for PHP.
*
* Copyright (c) 2016 Richard Klees <[email protected]>
*
* This software is licensed under The MIT License. You should have received
* a copy of the license along with the code.
*/
$base_dir = __DIR__;
$src_dir = "$base_dir/src";
$vendor_dir = "$base_dir/vendor";
$dicto_path = "$base_dir/dicto.php";
$build_dir = __DIR__;
$phar_name = "dicto.phar";
$phar_path = "$build_dir/$phar_name";
// Remove previously created phar if one exists.
if (file_exists($phar_path)) {
unlink($phar_path);
}
$phar = new Phar
( $phar_path
, FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME
, $phar_name
);
$phar->buildFromDirectory($base_dir);
$phar->setStub(<<<STUB
#!/usr/bin/env php
<?php
Phar::mapPhar();
include "phar://$phar_name/dicto.php";
__HALT_COMPILER();
STUB
);
chmod($phar_path, 0755);