-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuilder.php
More file actions
31 lines (25 loc) · 757 Bytes
/
builder.php
File metadata and controls
31 lines (25 loc) · 757 Bytes
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
<?php
/**
* @file builder.php
* Compiler for Cliphp.
*
* @version 1.0.0
* @author Daniel da Silva
*/
$pharName = (isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : 'cliphp') . '.phar';
$srcRoot = "src";
$buildRoot = "build";
$phar = new Phar("$buildRoot/$pharName", FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME, $pharName);
//$phar = $phar->convertToExecutable(Phar::ZIP);
// Include everything in the source directory.
$phar->buildFromDirectory($srcRoot);
// Set index file manually to set APP_PATH.
$phar["index.php"] = <<<EOF
<?php
define('APP_DIR', 'phar://{$pharName}');
define('ENVIRONMENT', 'production');
require 'core/bootstrap.php';
?>
EOF;
$phar->setStub($phar->createDefaultStub("index.php"));
?>