You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

compile 1.6 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/env php
  2. <?php
  3. $phar_file = 'logchecker.phar';
  4. if (file_exists($phar_file)) {
  5. unlink($phar_file);
  6. }
  7. $phar = new Phar(__DIR__.'/../'.$phar_file, FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME, $phar_file);
  8. $phar->startBuffering();
  9. $base_dir = realpath(__DIR__.'/../');
  10. $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(realpath(__DIR__.'/../src'), RecursiveDirectoryIterator::SKIP_DOTS));
  11. foreach ($it as $entry) {
  12. $phar->addFile($entry->getPathName(), str_replace($base_dir, '', $entry->getPathName()));
  13. }
  14. $vendor = [
  15. 'composer',
  16. 'psr',
  17. 'symfony'
  18. ];
  19. foreach ($vendor as $dir) {
  20. $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(realpath(__DIR__.'/../vendor/'.$dir), RecursiveDirectoryIterator::SKIP_DOTS));
  21. foreach ($it as $entry) {
  22. $phar->addFile($entry->getPathName(), str_replace($base_dir, '', $entry->getPathName()));
  23. }
  24. }
  25. $phar->addFile(realpath(__DIR__.'/../vendor/autoload.php'), 'vendor/autoload.php');
  26. $phar->addFile(realpath(__DIR__.'/../composer.json'), 'composer.json');
  27. $phar->addFile(realpath(__DIR__.'/../LICENSE.md'), 'LICENSE.md');
  28. $phar->addFile(realpath(__DIR__.'/../README.md'), 'README.md');
  29. $bin_file = file_get_contents(__DIR__.'/logchecker');
  30. $bin_file = preg_replace('{^#!/usr/bin/env php\s*}', '', $bin_file);
  31. $phar->addFromString('bin/logchecker', $bin_file);
  32. $stub = <<<PHP
  33. #!/usr/bin/env php
  34. <?php
  35. Phar::mapPhar('{$phar_file}');
  36. require 'phar://{$phar_file}/bin/logchecker';
  37. __HALT_COMPILER();
  38. PHP;
  39. $phar->setStub($stub);
  40. $phar->stopBuffering();
  41. //$phar->compress(Phar::GZ);
  42. echo "{$phar_file} generated...";