Skip to content

Commit

Permalink
add custom stub to demonstration --manifest option capability
Browse files Browse the repository at this point in the history
  • Loading branch information
llaville committed Mar 18, 2023
1 parent 2b0ac79 commit 07f14a0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/app-fixtures/app-fixtures-box.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"main": null,
"stub": "app-fixtures-stub.php",
"output": "app-fixtures.phar",
"directories": ["bin", "src", "vendor"],
"directories-bin": ["../../vendor/humbug/box/res/requirement-checker"],
Expand Down
33 changes: 33 additions & 0 deletions examples/app-fixtures/app-fixtures-stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env php
<?php
// app-fixtures-stub.php
/*
* Generated by Humbug Box 4.3.8@5534406.
*
* @link https://github.com/humbug/box
*/

Phar::mapPhar('app-fixtures-alias.phar');

if ($argc > 1 && $argv[1] === '--manifest') {
$resources = $argc > 2 ? [$argv[2]] : ['manifest.txt', 'manifest.xml', 'sbom.xml', 'sbom.json'];

foreach ($resources as $resource) {
$filename = "phar://app-fixtures-alias.phar/{$resource}";
if (file_exists($filename)) {
echo (file_get_contents($filename));
$status = 0;
break;
} elseif (count($resources) === 1) {
echo sprintf('Manifest "%s" is not available in this PHP Archive.', $resource), PHP_EOL;
$status = 1;
break;
}
}
exit($status);
}

require 'phar://app-fixtures-alias.phar/.box/bin/check-requirements.php';
require 'phar://app-fixtures-alias.phar/index.php';

__HALT_COMPILER(); ?>

0 comments on commit 07f14a0

Please sign in to comment.