<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LAMPlights &#187; build</title>
	<atom:link href="http://www.hermanradtke.com/blog/tag/build/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hermanradtke.com</link>
	<description>Personal anecdotes from my experiences using the LAMP stack</description>
	<lastBuildDate>Wed, 25 Jan 2012 18:14:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Phing &#8211; phplint task</title>
		<link>http://www.hermanradtke.com/blog/phing-phplint-task/</link>
		<comments>http://www.hermanradtke.com/blog/phing-phplint-task/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 02:54:57 +0000</pubDate>
		<dc:creator>Herman Radtke</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[phing]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.hermanradtke.com/blog/?p=262</guid>
		<description><![CDATA[Phing is a PHP port of Java Ant.  It is a great tool to use in development.  It standardizes a lot of build scripts you would have to maintain internally.  Unfortunately, examples seem to be lacking.  As a quick introduction to Phing, I will show how you can check all your php scripts for syntax [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://phing.info/trac/">Phing</a> is a PHP port of Java Ant.  It is a great tool to use in development.  It standardizes a lot of build scripts you would have to maintain internally.  Unfortunately, examples seem to be lacking.  As a quick introduction to Phing, I will show how you can check all your php scripts for syntax errors.</p>
<p><span id="more-262"></span> If you have never heard of Phing before, I suggest you visit the <a href="http://phing.info/docs/guide/current/chapters/GettingStarted.html">getting started page</a>.</p>
<p>The phplint task will syntax check one or more files containing php source code.  All it requires is a list of files.</p>
<p>Here is the sample build.xml file:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;MyPhpProject&quot;</span> <span style="color: #000066;">basedir</span>=<span style="color: #ff0000;">&quot;.&quot;</span> <span style="color: #000066;">default</span>=<span style="color: #ff0000;">&quot;lint&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;lint&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phplint<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileset</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;*.php&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;**/*.php&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fileset<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phplint<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>We created a target called "lint".  This will allow us to call lint from the command line.  In that target we specify a single task: phplint.  The phplint task will call "php -l" on each filename provided.  Within that task we specify a <a href="http://phing.info/docs/guide/current/chapters/appendixes/AppendixD-CoreTypes.html#Fileset">fileset</a> type.  The fileset type is what provides the phplint task with files to syntax check.</p>
<p>The fileset type can get pretty complex.  I have intentionally kept it simple.  The dir attribute on the fileset type specifies the current directory.  The first include element will match any file with a ".php" extension in the current directory.  The second include element will match any file with a ".php" extension in a sub-directory.</p>
<p>Here is a visualization of how the fileset is working:</p>
<pre>
app/
    build.xml <-- will not match
    foo.php <-- will match
    bar.php <-- will match
    includes/
        baz.php <-- will match
        special/
            special1.php <-- will match
            special2.inc <-- will not match
    sql/
        schema.sql <-- will not match
</pre>
<p>Place the build.xml file at the root of your applications directory structure.  You can move it to another folder after you get more comfortable with phing.</p>
<p>From the command line run: phing lint</p>
<p><img alt="" src="http://farm3.static.flickr.com/2648/4116616256_327cf8fb1a.jpg" title="phplint task" class="alignnone" width="500" height="196" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hermanradtke.com/blog/phing-phplint-task/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

