You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
<?php
|
|
// https://blog.programster.org/creating-phar-files
|
|
$pharFile = 'neatoDeploy.phar';
|
|
|
|
// clean up
|
|
if (file_exists($pharFile)) {
|
|
unlink($pharFile);
|
|
}
|
|
|
|
if (file_exists($pharFile . '.gz')) {
|
|
unlink($pharFile . '.gz');
|
|
}
|
|
|
|
// create phar
|
|
$phar = new Phar($pharFile);
|
|
|
|
// start buffering. Mandatory to modify stub to add shebang
|
|
$phar->startBuffering();
|
|
|
|
// Add the rest of the apps files
|
|
$phar->buildFromDirectory(
|
|
__DIR__ . '/../app', // Base APP folder
|
|
'/\.php$/', // Regular expression to include only PHP files
|
|
);
|
|
|
|
$phar->stopBuffering();
|
|
|
|
//$phar->setSignatureAlgorithm(Phar::SHA512);
|
|
$private_key = file_get_contents("private.pem");
|
|
$phar->setSignatureAlgorithm(Phar::OPENSSL, $private_key);
|
|
|
|
// Create the default stub from main.php entrypoint
|
|
$defaultStub = $phar->createDefaultStub('neato.php');
|
|
|
|
// Customize the stub to add the shebang
|
|
$stub = "\n" . $defaultStub;
|
|
|
|
// Add the stub
|
|
$phar->setStub($stub);
|
|
|
|
// plus - compressing it into gzip
|
|
$phar->compressFiles(Phar::GZ);
|
|
|
|
# Make the file executable
|
|
chmod(__DIR__ . '/'. $pharFile, 0770);
|
|
|
|
echo "$pharFile successfully created" . PHP_EOL;
|
|
|