#!/usr/bin/env php getRealPath(), '\\', '/'), strtr($b->getRealPath(), '\\', '/')); }; function addFile($phar, $file) { $path = strtr(str_replace(dirname(dirname(__DIR__)).DIRECTORY_SEPARATOR, '', $file->getRealPath()), '\\', '/'); $content = file_get_contents($file); $phar->addFromString($path, $content); } $phar = new Phar( $filePath, FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME, $filename ); $phar->setSignatureAlgorithm(\Phar::SHA1); $phar->startBuffering(); addFile($phar, new SplFileInfo('boot.php', $rootDir . '/boot.php', 'boot.php')); addFile($phar, new SplFileInfo('composer.json', $rootDir . '/composer.json', 'composer.json')); addFile($phar, new SplFileInfo('vendor/autoload.php', $rootDir . '/vendor/autoload.php', 'vendor/autoload.php')); $finder = new Finder(); $finder->files() ->ignoreVCS(true) ->name('*.php') ->in([ $rootDir . '/src/', $rootDir . '/vendor/composer', $rootDir . '/vendor/whatthejeff', ]) ->sort($finderSort) ; foreach ($finder as $file) { addFile($phar, $file); } $phar->setStub($stub); $phar->stopBuffering(); chmod($filePath, 0775);