Files
interview-demo-code/scripts/ci/create-phar.php
Nikita Kiselev 846fa64fb4 feat: WIP
2025-07-10 18:31:02 +03:00

38 lines
750 B
PHP

<?php
$sourcePath = $argv[1] ?? null;
$pharFile = $argv[2] ?? null;
if (! $sourcePath) {
throw new InvalidArgumentException('Source path must be provided');
}
if (! $pharFile) {
throw new InvalidArgumentException('Phar file must be provided');
}
// Remove old file if exists
if (file_exists($pharFile)) {
unlink($pharFile);
}
// Create new Phar archive
$phar = new Phar($pharFile);
// Start buffering
$phar->startBuffering();
// Add files from source directory
$phar->buildFromDirectory($sourcePath);
// (Optional) Set stub file — main entry point
// $phar->setStub($phar->createDefaultStub('index.php'));
$phar->compressFiles(Phar::GZ);
// Stop buffering and write
$phar->stopBuffering();
echo "Phar created: $pharFile\n";