script to generate phar file
[bdrem.git] / src / phar-stub.php
diff --git a/src/phar-stub.php b/src/phar-stub.php
new file mode 100644 (file)
index 0000000..3c80130
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+if (!in_array('phar', stream_get_wrappers()) || !class_exists('Phar', false)) {
+    echo "Phar extension not avaiable\n";
+    exit(255);
+}
+
+$web = 'www/index.php';
+$cli = 'bin/bdrem.php';
+
+function rewritePath($path)
+{
+    if ($path == '' || $path == '/') {
+        return 'www/index.php';
+    }
+    return $path;
+}
+
+//Phar::interceptFileFuncs();
+set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
+Phar::webPhar(null, $web, null, array(), 'rewritePath');
+include 'phar://' . __FILE__ . '/' . $cli;
+__HALT_COMPILER();
+?>