Skip to content

Instantly share code, notes, and snippets.

@casimiroarruda
Created September 10, 2012 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save casimiroarruda/3688544 to your computer and use it in GitHub Desktop.
Save casimiroarruda/3688544 to your computer and use it in GitHub Desktop.
Exemplo de buildfile phing 2
<?xml version="1.0"?>
<project basedir="." default="start">
<property file="build.properties" />
<target name="start" depends="cleanup,dirs,bootstrap,frontcontroller" />
<target name="cleanup">
<delete dir="application" includeemptydirs="true" verbose="false" failonerror="true" />
<delete dir="vendor" includeemptydirs="true" verbose="false" failonerror="true" />
<delete dir="tests" includeemptydirs="true" verbose="false" failonerror="true" />
<delete dir="web" includeemptydirs="true" verbose="false" failonerror="true" />
<delete dir="log" includeemptydirs="true" verbose="false" failonerror="true" />
<delete dir="cache" includeemptydirs="true" verbose="false" failonerror="true" />
</target>
<target name="dirs">
<mkdir dir="application/library/${vendor}/${project.name}" />
<mkdir dir="tests/${$vendor}/${project.name}" />
<mkdir dir="vendor" />
<mkdir dir="web/script" />
<mkdir dir="web/style" />
<mkdir dir="web/media" />
<mkdir dir="log"/>
<mkdir dir="cache"/>
<chmod mode="777" file="log"/>
<chmod mode="777" file="cache"/>
</target>
<target name="bootstrap">
<property name="autoloader" value="spl_autoload_register(function ($classname) {&#10;
$classname = ltrim($classname, '\\');&#10;
preg_match('/^(.+)?([^\\\\]+)$/U', $classname, $match);&#10;
$classname = str_replace('\\', '/', $match[1]).str_replace(['\\', '_'], '/', $match[2]).'.php';&#10;
require_once $classname;&#10;});"/>
<property name="app_includepath" value="set_include_path(__DIR__.'/library'.PATH_SEPARATOR.get_include_path());"/>
<property name="test_includepath" value="set_include_path(__DIR__.'/../library'.PATH_SEPARATOR.__DIR__.'/../tests'.get_include_path());"/>
<property name="app_bootstrap" value="&lt;?php&#10;${app_includepath}&#10;${autoloader}"/>
<property name="test_bootstrap" value="&lt;?php&#10;${test_includepath}&#10;${autoloader}"/>
<echo msg="${app_bootstrap}" file="application/bootstrap.php"/>
<echo msg="${test_bootstrap}" file="tests/bootstrap.php"/>
</target>
<target name="frontcontroller">
<echo msg="&lt;?php&#10;require __DIR__.'/../application/bootstrap.php';" file="web/index.php"/>
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment