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