* @license http://github.com/basdenooijer/solarium/raw/master/COPYING * @link http://www.solarium-project.org/ */ // Check phar.readonly ini setting if (ini_get('phar.readonly') == '1') { exit("Your php.ini has phar.readonly enabled. Phar cannot be created. Please alter your php.ini first.\n"); } // You can optionally use arguments to enable compression and whitespace/comment stripping. // Example: "php buildphar.php -s 1 -c 1" // -c with a value of 1 enables compression, multiple phars will be created // -s with a value of 1 enables stripping $options = getopt('s:c:'); $compress = (isset($options['c']) && $options['c'] == '1'); $strip = (isset($options['s']) && $options['s'] == '1'); $start = microtime(true); // Create a new Solarium phar file @unlink('solarium.phar'); $phar = new Phar('solarium.phar', 0, 'solarium.phar'); $phar->setStub(file_get_contents("stub.php")); $phar->setSignatureAlgorithm(Phar::SHA1); // Add files to the phar $basePath = realpath(__DIR__."/../library/Solarium"); if ($strip) { $directoryIterator = new RecursiveIteratorIterator (new RecursiveDirectoryIterator ($basePath), RecursiveIteratorIterator::SELF_FIRST); foreach ($directoryIterator as $file) { if ( preg_match ('/\\.php$/i', $file) ) { $phar->addFromString (substr ($file, strlen ($basePath) + 1), php_strip_whitespace ($file)); } } } else { $phar->buildFromDirectory($basePath, '/\.php$/'); } // Create compressed versions if ($compress) { $phar->compress(Phar::BZ2); $phar->compress(Phar::GZ); } $time = round(microtime(true)-$start,5); echo "\nDONE ($time seconds)\n\n";