build 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/usr/bin/env php
  2. <?php
  3. /**
  4. * Build the whole library into a single file
  5. * as an easy drop in solution as opposed to
  6. * relying on autoloader. Sometimes we just
  7. * want to hack with an API as a one off thing.
  8. * Httpful should make this easy.
  9. */
  10. function exit_unless($condition, $msg = null) {
  11. if ($condition)
  12. return;
  13. echo "[FAIL]\n$msg\n";
  14. exit(1);
  15. }
  16. // Create the Httpful Phar
  17. echo "Building Phar... ";
  18. $base_dir = dirname(__FILE__);
  19. $source_dir = $base_dir . '/src/Httpful/';
  20. $phar_path = $base_dir . '/downloads/httpful.phar';
  21. $phar = new Phar($phar_path, 0, 'httpful.phar');
  22. $stub = <<<HEREDOC
  23. <?php
  24. // Phar Stub File
  25. Phar::mapPhar('httpful.phar');
  26. include('phar://httpful.phar/Httpful/Bootstrap.php');
  27. \Httpful\Bootstrap::pharInit();
  28. __HALT_COMPILER();
  29. HEREDOC;
  30. try {
  31. $phar->setStub($stub);
  32. } catch(Exception $e) {
  33. $phar = false;
  34. }
  35. exit_unless($phar, "Unable to create a phar. Make certain you have phar.readonly=0 set in your ini file.");
  36. $phar->buildFromDirectory(dirname($source_dir));
  37. echo "[ OK ]\n";
  38. // Add it to git!
  39. //echo "Adding httpful.phar to the repo... ";
  40. //$return_code = 0;
  41. //passthru("git add $phar_path", $return_code);
  42. //exit_unless($return_code === 0, "Unable to add download files to git.");
  43. //echo "[ OK ]\n";
  44. echo "\nBuild completed successfully.\n\n";