setSignatureAlgorithm(\Phar::SHA1); $phar->startBuffering(); $phar->buildFromDirectory(__DIR__, '/\.php$/'); $defaultStub = $phar->createDefaultStub('chash.php'); // Create a custom stub to add the shebang $stub = "#!/usr/bin/env php \n".$defaultStub; // Add the stub $phar->setStub($stub); $phar->stopBuffering();