summaryrefslogtreecommitdiff
path: root/ext/phar/phar/phar.php
blob: f6f26c23f28cd601011db09cb7154e704b9925f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/local/bin/php
<?php

/** @file phar.php
 * @ingroup Phar
 * @brief class CLICommand
 * @author  Marcus Boerger
 * @date    2007 - 2008
 *
 * Phar Command
 */

if (!extension_loaded('phar'))
{
	if (!class_exists('PHP_Archive', 0)) {
		echo "Neither Extension Phar nor class PHP_Archive are available.\n";
		exit(1);
	}
	if (!in_array('phar', stream_get_wrappers())) {
		stream_wrapper_register('phar', 'PHP_Archive');
	}
	if (!class_exists('Phar',0)) {
		require 'phar://'.__FILE__.'/phar.inc';
	}
}

foreach(array("SPL", "Reflection") as $ext)
{
	if (!extension_loaded($ext)) {
		echo "$argv[0] requires PHP extension $ext.\n";
		exit(1);
	}
}

function command_include($file)
{
	$file = 'phar://' . __FILE__ . '/' . $file;
	if (file_exists($file)) {
		include($file);
	}
}

function command_autoload($classname)
{
	command_include(strtolower($classname) . '.inc');
}

Phar::mapPhar();

spl_autoload_register('command_autoload');

new PharCommand($argc, $argv);

__HALT_COMPILER();

?>