<?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>BinaryKitten&#039;s Development Dropbox &#187; Standards</title>
	<atom:link href="http://binarykitten.com/tag/standards/feed" rel="self" type="application/rss+xml" />
	<link>http://binarykitten.com</link>
	<description>Curently a work in progress. Please be patient</description>
	<lastBuildDate>Thu, 27 Oct 2011 21:49:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Integrating PHP CodeSniffer with Activestate Komodo Edit</title>
		<link>http://binarykitten.com/dev/219-integrating-php-codesniffer-with-activestate-komodo-edit.html</link>
		<comments>http://binarykitten.com/dev/219-integrating-php-codesniffer-with-activestate-komodo-edit.html#comments</comments>
		<pubDate>Mon, 15 Feb 2010 02:34:26 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Activestate]]></category>
		<category><![CDATA[Coding Standards]]></category>
		<category><![CDATA[Komodo]]></category>
		<category><![CDATA[Komodo Edit]]></category>
		<category><![CDATA[PHP_CodeSniffer]]></category>
		<category><![CDATA[Standards]]></category>

		<guid isPermaLink="false">http://binarykitten.me.uk/?p=219</guid>
		<description><![CDATA[I&#8217;ve recently been looking into standards of code and how they would apply to myself and my code. To enable this, I&#8217;ve recently installed PHP_CodeSniffer and for a few days been using this on the command line.. which by itself isn&#8217;t bad, though I really wanted to have something inside my editor of choice (happens [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently been looking into standards of code and how they would apply to myself and my code. To enable this, I&#8217;ve recently installed PHP_CodeSniffer and for a few days been using this on the command line.. which by itself isn&#8217;t bad, though I really wanted to have something inside my editor of choice (happens to be Komodo Edit).<span id="more-219"></span></p>
<h2>Setting up Pear</h2>
<p>Since I will be using Pear to install the code sniffer we might as well cover that to start with.<br />
There are lots of tutorials out there with the aim of helping you to get pear installed no matter what the platform. I Will leave that job for them. What I will do is cover how to get it running easily with WampServer from <a href="http://www.wampserver.com/en/">http://www.wampserver.com/en/</a> Please do Note that this is all on a Windows Based machine</p>
<ol>
<li>Open a command prompt</li>
<li>Make a note of your php Directory&#8230; you will need this in a few places<br />
&#8220;WAMPDIR\bin\php\PHPVERSION&#8221;<br />
where WAMPDIR = the directory WampServer is installed to<br />
and PHPVERSION = php+version number..<br />
i&#8217;m using php 5.2.11 on wampserver so the location for me looks like this<br />
&#8220;D:\Wamp\bin\php\php5.2.11&#8243;</li>
<li>CD /D PHPDIR &#8211; where PHPDIR is the location you should have noted down in the last step</li>
<li>Type go-pear and watch as it installs</li>
<li>bring up the Advanced system properties</li>
<li>Environment Variables</li>
<li>Edit Path to add your php folder prefixed with a ;<br />
e.g. for my path was already c:\SharedLibs  so that became<br />
c:\SharedLibs;d:\wamp\bin\php\php5.2.11 &#8211; Close and save all settings</li>
</ol>
<h2>Installing PHP_CodeSniffer via Pear</h2>
<p>Now that I had pear installed I could use it to install PHP_CodeSniffer, this was a simple task with 1 line of code..<br />
<code>pear install PHP_Codesniffer</code> and that was it.. Actually I tell a small lie here, to make it work within the confines of other folders was to do as follows:</p>
<ol>
<li>Open the phpcs.bat file that resides in the php folder outlined above in notepad or similar editor</li>
<li>Change &#8220;./php.exe&#8221; to &#8220;php.exe&#8221;, save the file and close</li>
</ol>
<p>Now we are ready to run PHP_Codesniffer.</p>
<h2>Setting up Komodo Edit</h2>
<p>To start with, I use Komodo Edit for this, that is because that is what I use. I thoroughly recommend it over the likes of notepad++ etc mainly because of its feature set, and the way that it handles code completion from the project. But enough of all this, lets get down to creating a &#8220;run Command&#8221; for the active Tab/File in Komodo.</p>
<ol>
<li>Click Tools, then Run Commandin the R<span style="text-decoration: underline;">u</span>n box enter the following:</li>
<li><code>phpcs -n --standard=%(ask:Which Standard do you wish to use?:ZEND) --report=emacs "%F"</code>Check the <span style="text-decoration: underline;">A</span>dd to Toolbox optionToggle the More options So you can see the Advanced Options Panemake sure the &#8220;Run in&#8221; is set to Command Output TabCheck the &#8220;Parse Output with:&#8221; checkbox and enter the following in the select field:
<pre class="brush: text">
^(?P&lt;file&gt;.*):(?P&lt;line&gt;\d+):(?P&lt;column&gt;\d+):(?P&lt;content&gt;.*)
                     </pre>
</li>
<li>Check the &#8220;Show parsed output as a list&#8221; checkbox</li>
<li>Click the <span style="text-decoration: underline;">N</span>ew button to begin adding a envrionment variable</li>
<li>Set the &#8220;Variable Name&#8221; to PATH and the &#8220;Variable Value&#8221; to the location of PHP_Codesniffer &#8211; If you are following through this is the same as step 2 of &#8220;setting up pear&#8221;- then click ok</li>
<li>click <span style="text-decoration: underline;">R</span>un button &#8211; PHP_CodeSniffer will run and then will ask you for the standard you wish to check against .. by default It&#8217;s set to ZEND</li>
<li>Lastly right click the toolbox entry and bring up the properties. The Top left Text entry is the &#8220;nice name&#8221; for this. You can also assign keys to launch this command later</li>
</ol>
<p>Now you have successfully created a run Tool in Komodo that will run PHP_Codesniffer against the active file and will output the results in a nice list in the command output tab at the bottom panel. I chose the emacs output method as it was easier to get nice looking format without the \&#8221; escape sequence appearing in the &#8220;content&#8221;. The Reason for the regex and the list is that it will now allow you to double click and entry and it will jump to the right spot in the file.</p>
<p>I&#8217;ve also included a Komodo Package of 3 run time commands .. 1 for file, 1 for all files in the project and 1 for all files the directory shared with the currently active file. You can download them here: <a href="/CodeSniff.kpz">CodeSniff Package</a> &#8211; <strong>Recommended to Right-Click &#8211; Save Target as etc</strong> &#8211; This packages comes with predefined keystrokes </p>
<ul>
<li>CTRL+L,CTRL+S,CTRL+F to Codesniff the currently Active file</li>
<li>CTRL+L,CTRL+S,CTRL+P to Codesniff all files in the Project</li>
<li>CTRL+L,CTRL+S,CTRL+D to Codesniff all files in the Active File&#8217;s Directory</li>
</ul>
<p>I do hope that this will prove as useful for someone else as it has for me, comments are welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.com/dev/219-integrating-php-codesniffer-with-activestate-komodo-edit.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

