startBuffering(); // Create the default stub from main.php entrypoint $defaultStub = $phar->createDefaultStub('neato.php'); // Add the rest of the apps files $phar->buildFromDirectory( __DIR__ . '/../app', // Base APP folder '/\.php$/', // Regular expression to include only PHP files ); // Customize the stub to add the shebang $stub = "\n" . $defaultStub; // Add the stub $phar->setStub($stub); $phar->stopBuffering(); // plus - compressing it into gzip $phar->compressFiles(Phar::GZ); # Make the file executable chmod(__DIR__ . '/'. $pharFile, 0770); echo "$pharFile successfully created" . PHP_EOL;