xref: /PHP-5.3/ext/phar/phar/phar.php (revision 821bab83)
1#!/usr/local/bin/php
2<?php
3
4/** @file phar.php
5 * @ingroup Phar
6 * @brief class CLICommand
7 * @author  Marcus Boerger
8 * @date    2007 - 2008
9 *
10 * Phar Command
11 */
12
13if (!extension_loaded('phar'))
14{
15	if (!class_exists('PHP_Archive', 0)) {
16		echo "Neither Extension Phar nor class PHP_Archive are available.\n";
17		exit(1);
18	}
19	if (!in_array('phar', stream_get_wrappers())) {
20		stream_wrapper_register('phar', 'PHP_Archive');
21	}
22	if (!class_exists('Phar',0)) {
23		require 'phar://'.__FILE__.'/phar.inc';
24	}
25}
26
27foreach(array("SPL", "Reflection") as $ext)
28{
29	if (!extension_loaded($ext)) {
30		echo "$argv[0] requires PHP extension $ext.\n";
31		exit(1);
32	}
33}
34
35function command_include($file)
36{
37	$file = 'phar://' . __FILE__ . '/' . $file;
38	if (file_exists($file)) {
39		include($file);
40	}
41}
42
43function command_autoload($classname)
44{
45	command_include(strtolower($classname) . '.inc');
46}
47
48Phar::mapPhar();
49
50spl_autoload_register('command_autoload');
51
52new PharCommand($argc, $argv);
53
54__HALT_COMPILER();
55
56?>