-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.php
37 lines (27 loc) · 875 Bytes
/
build.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
<?php
$pharFile = 'ethical.phar';
// clean up
if (file_exists($pharFile)) {
unlink($pharFile);
}
if (file_exists($pharFile . '.gz')) {
unlink($pharFile . '.gz');
}
// create phar
$phar = new Phar($pharFile);
$phar->startBuffering();
// Get the default stub. You can create your own if you have specific needs
$defaultStub = $phar->createDefaultStub('src/App.php');
$phar->buildFromDirectory(__DIR__ . '/src', '/.php$/');
$phar->buildFromDirectory(__DIR__ . '/vendor', '/.php$/');
$phar->buildFromDirectory(__DIR__, '/.php$/');
// Customize the stub to add the shebang
$stub = "#!/usr/bin/php \n" . $defaultStub;
// Add the stub
$phar->setStub($stub);
$phar->stopBuffering();
// plus - compressing it into gzip
$phar->compressFiles(Phar::GZ);
# Make the file executable
chmod(__DIR__ . '/' . $pharFile, 0770);
echo "$pharFile successfully created" . PHP_EOL;