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.
 
 
 
 
 
 

63 lines
1.3 KiB

  1. <?php
  2. # required: PHP 5.3+ and zlib extension
  3. // ini option check
  4. if (ini_get('phar.readonly')) {
  5. echo "php.ini: set the 'phar.readonly' option to 0 to enable phar creation\n";
  6. exit(1);
  7. }
  8. // output name
  9. $pharName = 'Matrix.phar';
  10. // target folder
  11. $sourceDir = __DIR__ . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR;
  12. // default meta information
  13. $metaData = array(
  14. 'Author' => 'Mark Baker <mark@lange.demon.co.uk>',
  15. 'Description' => 'PHP Class for working with Matrix numbers',
  16. 'Copyright' => 'Mark Baker (c) 2013-' . date('Y'),
  17. 'Timestamp' => time(),
  18. 'Version' => '0.1.0',
  19. 'Date' => date('Y-m-d')
  20. );
  21. // cleanup
  22. if (file_exists($pharName)) {
  23. echo "Removed: {$pharName}\n";
  24. unlink($pharName);
  25. }
  26. echo "Building phar file...\n";
  27. // the phar object
  28. $phar = new Phar($pharName, null, 'Matrix');
  29. $phar->buildFromDirectory($sourceDir);
  30. $phar->setStub(
  31. <<<'EOT'
  32. <?php
  33. spl_autoload_register(function ($className) {
  34. include 'phar://' . $className . '.php';
  35. });
  36. try {
  37. Phar::mapPhar();
  38. } catch (PharException $e) {
  39. error_log($e->getMessage());
  40. exit(1);
  41. }
  42. include 'phar://functions/sqrt.php';
  43. __HALT_COMPILER();
  44. EOT
  45. );
  46. $phar->setMetadata($metaData);
  47. $phar->compressFiles(Phar::GZ);
  48. echo "Complete.\n";
  49. exit();