--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<project name="phancap" default="phar" basedir=".">
+
+ <property name="version" value="0.1.0" />
+ <property name="pharfile" value="${phing.dir}/dist/${phing.project.name}-${version}.phar" />
+ <property name="libdir" value="${phing.dir}/lib"/>
+
+ <fileset id="fs.phar" dir="${phing.dir}">
+<!---->
+ <include name="data/**"/>
+ <include name="lib/**"/>
+ <include name="src/**"/>
+ <include name="www/**"/>
+
+ <include name="README.rst"/>
+
+ <exclude name="data/phancap.config.php"/>
+<!--
+ <include name="www/index.php"/> -->
+ </fileset>
+
+ <typedef name="pearPackageFileSet" classname="phing.types.PearPackageFileSet" />
+
+ <target name="phar" depends="collectdeps"
+ description="Create zip file for release"
+ >
+ <mkdir dir="${phing.dir}/dist/"/>
+ <delete file="${pharfile}"/>
+ <pharpackage basedir="${phing.dir}"
+ destfile="${pharfile}"
+ stub="${phing.dir}/src/phar-stub.php"
+ alias="test.phar"
+ >
+ <fileset refid="fs.phar"/>
+ </pharpackage>
+ <!--
+ <exec executable="bzip2" dir="${phing.dir}/dist">
+ <arg value="-kf"/>
+ <arg file="${pharfile}"/>
+ </exec>
+ -->
+ </target>
+
+
+ <target name="collectdeps" description="Copy package dependencies to lib/">
+ <delete dir="${libdir}"/>
+ <mkdir dir="${libdir}"/>
+
+ <pearPackageFileset id="dep-PEAR" package="pear.php.net/PEAR">
+ <include name="PEAR/Exception.php"/>
+ <include name="PEAR.php"/>
+ <include name="PEAR5.php"/>
+ </pearPackageFileset>
+ <pearPackageFileset id="dep-Getopt" package="pear.php.net/Console_Getopt" />
+
+ <copy todir="${libdir}">
+ <fileset refid="dep-PEAR"/>
+ <fileset refid="dep-Getopt"/>
+ </copy>
+ </target>
+
+
+ <target name="docs" description="render documentation">
+ <rst file="README.rst"/>
+ </target>
+
+</project>
--- /dev/null
+<?php
+/**
+ * Phar stub file for bdrem. Handles startup of the .phar file.
+ *
+ * PHP version 5
+ *
+ * @category Tools
+ * @package Phancap
+ * @author Christian Weiske <cweiske@cweiske.de>
+ * @copyright 2014 Christian Weiske
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
+ * @link http://cweiske.de/phancap.htm
+ */
+if (!in_array('phar', stream_get_wrappers()) || !class_exists('Phar', false)) {
+ echo "Phar extension not avaiable\n";
+ exit(255);
+}
+
+$web = 'www/index.php';
+
+/**
+ * Rewrite the HTTP request path to an internal file.
+ * Maps "" and "/" to "www/index.php".
+ *
+ * @param string $path Path from the browser, relative to the .phar
+ *
+ * @return string Internal path.
+ */
+function rewritePath($path)
+{
+ if ($path == '' || $path == '/') {
+ return 'www/index.php';
+ } else if ($path == '/get' || $path == '/get.php') {
+ return 'www/get.php';
+ } else if ($path == '/setup' || $path == '/setup.php') {
+ return 'www/setup.php';
+ }
+ return $path;
+}
+
+//Phar::interceptFileFuncs();
+set_include_path(
+ 'phar://' . __FILE__
+ . PATH_SEPARATOR . 'phar://' . __FILE__ . '/lib/'
+);
+Phar::webPhar(null, $web, null, array(), 'rewritePath');
+
+//work around https://bugs.php.net/bug.php?id=52322
+//require 'phar://' . __FILE__ . '/' . $web;
+echo "cli\n";
+__HALT_COMPILER();
+?>