diff --git a/bin/build b/bin/build index 5d43883..639bc6f 100644 --- a/bin/build +++ b/bin/build @@ -37,13 +37,26 @@ if (1 == ini_get('phar.readonly')) { // create phar $p = new Phar($output); +// start buffering. Mandatory to modify stub. +$p->startBuffering(); + +// pointing main file which requires all classes +$defaultStub = $p->createDefaultStub('index.php', '/index.php'); + // creating our library using whole directory $p->buildFromDirectory($input); -// pointing main file which requires all classes -$p->setDefaultStub('index.php', '/index.php'); +// Create a custom stub to add the shebang +$stub = "#!/usr/bin/env php\n" . $defaultStub; + +// Add the stub +$p->setStub($stub); + +$p->stopBuffering(); unset($p); rename($output, $finalOutput); +chmod($finalOutput, 0755); + echo "$output successfully created"; \ No newline at end of file