back to dev
[pharext/pharext] / src / pharext_installer.php
index 90c9f508688528bc4b5ceb28c24ea42c9fcd5af7..19386f203b87632bf1c1eea7d9841008cb1e14c4 100644 (file)
@@ -1,11 +1,38 @@
+#!/usr/bin/env php
 <?php
+
 /**
  * The installer sub-stub for extension phars
  */
 
-function __autoload($c) {
+namespace pharext;
+
+define("PHAREXT_PHAR", __FILE__);
+
+spl_autoload_register(function($c) {
        return include strtr($c, "\\_", "//") . ".php";
+});
+
+#include <pharext/Exception.php>
+#include <pharext/Tempname.php>
+#include <pharext/Tempfile.php>
+#include <pharext/Tempdir.php>
+#include <pharext/Archive.php>
+
+namespace pharext;
+
+if (extension_loaded("Phar")) {
+       \Phar::interceptFileFuncs();
+       \Phar::mapPhar();
+       $phardir = "phar://".__FILE__;
+} else {
+       $archive = new Archive(__FILE__);
+       $phardir = $archive->extract();
 }
 
-$installer = new pharext\Installer();
+set_include_path("$phardir:". get_include_path());
+
+$installer = new Installer();
 $installer->run($argc, $argv);
+
+__HALT_COMPILER();