Last Updated: February 25, 2016
·
1.509K
· MidnightLightning

PHP by Ant

Ant build scripts are designed for languages that need to be compiled, so for PHP web applications, there's not much need. However, auxiliary tools are making it useful to have some build scripts on hand.

Template

Your basic Ant template looks something like:

<?xml version="1.0" encoding="UTF-8"?>
<project name="MySite.com" default="default" basedir=".">
  <description>
    simple example build file
  </description>
  <target name="default">
    <exec executable="dir"></exec>
  </target>
</project>

Compass (CSS)

If you have a configuration file for your project set up properly, you just need:

<target name="compass">
  <exec executable="compass">
    <arg value="compile"/>
    <arg value="--environment"/>
    <arg value="production"/>
  </exec>
</target>

If you want all the configuration options set in the build script:

<target name="compass">
  <exec executable="compass">
    <arg value="compile"/>
    <arg value="--css_dir=inc"/>
    <arg value="--sass_dir=sass"/>
    <arg value="--output_style=compact"/>
  </exec>
</target>

SASS (CSS)

<pre class="prettyprint">
<target name="default">
  <exec executable="sass">
    <arg value="--style"/>
    <arg value="compact"/>
    <arg value="inc/main.scss:inc/main.css"/>
  </exec>
</target>
</pre>