<?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>Logaan's Site &#187; PHP</title>
	<atom:link href="http://www.logaans-site.co.uk/category/programming/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.logaans-site.co.uk</link>
	<description>In my own little world, world...world</description>
	<lastBuildDate>Thu, 29 Jul 2010 18:02:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>CyTS library stalling</title>
		<link>http://www.logaans-site.co.uk/2009/11/07/cyts-library-stalling/</link>
		<comments>http://www.logaans-site.co.uk/2009/11/07/cyts-library-stalling/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 17:48:19 +0000</pubDate>
		<dc:creator>Logaan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Teamspeak]]></category>

		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=513</guid>
		<description><![CDATA[On our guild website, we have a block in the portal that shows who is currently on teamspeak. This uses the CyTS library to connect and get such information and occasionally it would cause the portal to stop loading. In each case I would get home, load it up and not find any problems at [...]]]></description>
			<content:encoded><![CDATA[<p>On our guild website, we have a block in the portal that shows who is currently on teamspeak. This uses the CyTS library to connect and get such information and occasionally it would cause the portal to stop loading.</p>
<p>In each case I would get home, load it up and not find any problems at all. Well today was a different matter, I was able to pin point the exact issue. For some reason the library connects to the server but then stalls when receiving information from the server.</p>
<p>I should tell you know, this is not a perfect fix but it does the job. I did look into other options like switch socket blocking on and off and such other approaches, but it seems that if <em>fgets</em> reads more than 1 byte, it stalls. This is a bug in PHP that has hung around for a while.</p>
<p>I have changed the <em>_readcall</em> function to read the first byte, check it for failure then continue with the rest.</p>
<pre class="brush: php;">
function _readcall()
{
	if (!is_resource($this-&gt;sCon))
		return false;

	// HACK : Workaround to fail fast
	$first = fgets($this-&gt;sCon, 1);

	if($first === false)
		return false;

	$sRead = '';
	do
	{
		$cRead = $first.fgets($this-&gt;sCon);
		$first = '';

		$sRead .= $cRead;
	} while ($cRead != CYTS_SYN &amp;&amp; $cRead != CYTS_OK &amp;&amp; strtoupper(substr($cRead, 0, 5)) != &quot;ERROR&quot;);
	return $sRead;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.logaans-site.co.uk/2009/11/07/cyts-library-stalling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unit Testing with NetBeans and phpUnit</title>
		<link>http://www.logaans-site.co.uk/2008/11/12/unit-testing-with-netbeans-and-phpunit/</link>
		<comments>http://www.logaans-site.co.uk/2008/11/12/unit-testing-with-netbeans-and-phpunit/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 21:36:38 +0000</pubDate>
		<dc:creator>Logaan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[phpUnit]]></category>
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=174</guid>
		<description><![CDATA[Huzzah! I have found a way of being able to run the Unit tests in NetBeans. Since phpUnit is essentially a set of php scripts itself, I thought to myself there must be a way of invoking it. What I did was setup a source file as the boostrap for the Test Runner, set this [...]]]></description>
			<content:encoded><![CDATA[<p>Huzzah! I have found a way of being able to run the Unit tests in NetBeans.</p>
<p>Since phpUnit is essentially a set of php scripts itself, I thought to myself there must be a way of invoking it.</p>
<p>What I did was setup a source file as the boostrap for the Test Runner, set this file as NetBeans index file and from there you can just run it and see the test results in the output window or debug and it step into the test you are interested in.</p>
<p>It is not a fantastic solution but it is definately a stop gap until they do implement php Unit testing.</p>
<p>Heres my boostrap file for running tests:</p>
<pre class="brush: php; auto-links: false;">
&lt;php
$args = array(
__FILE__,
&quot;--coverage-html&quot;,
&quot;D:\\Logaan\\Documents\\XamppData\\htdocs\\FormManager\\CodeCoverage&quot;,
&quot;--verbose&quot;,
&quot;D:\\Logaan\\Documents\\XamppData\\htdocs\\FormManager\\tests\\TestSuite.php&quot;
);

$_SERVER['argv'] = $args;
$_SERVER['argc'] = count($args);

require_once 'PHPUnit/TextUI/Command.php';

// Exclude this file from code coverage
PHPUnit_Util_Filter::addFileToFilter(__FILE__);

?&gt;
</pre>
<p>Its very simple, what I am doing is hard coding my arguments into the server environment variable (you could use the arguments in the NetBeans configuration) which is where phpUnit gets the arguments from.<br />
Including the phpUnit TestUI test runner which has the main entry point, excluding this file from code coverage and then I just sit back and l let phpUnit run its course.</p>
<p><strong>This is only a work around until Netbeans supports phpUnit.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.logaans-site.co.uk/2008/11/12/unit-testing-with-netbeans-and-phpunit/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>NetBeans IDE</title>
		<link>http://www.logaans-site.co.uk/2008/11/12/netbeans-ide/</link>
		<comments>http://www.logaans-site.co.uk/2008/11/12/netbeans-ide/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 17:17:44 +0000</pubDate>
		<dc:creator>Logaan</dc:creator>
				<category><![CDATA[Logaan's Toolkit]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=171</guid>
		<description><![CDATA[The other day I had hit a brick wall, I was really struggling with part of my FormManager project and really needed to debug it. I started looking into XDebug and discovered what it could really do, and diving into the website I found they listed a set of compatible IDEs that could use the [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I had hit a brick wall, I was really struggling with part of my FormManager project and really needed to debug it.</p>
<p>I started looking into XDebug and discovered what it could really do, and diving into the website I found they listed a set of compatible IDEs that could use the extension to debug php. Since I had spurned eclipse I thought there was nothing else short of the Zend IDE that could help. Thats when I noticed NetBeans. The last time I had used NetBeans was back in college for some Java projects. I was really surprised when I found out that they offered a PHP IDE.</p>
<p>Within a couple of seconds of getting the project setup in the IDE it found the problem already for me. It does a much better job of context sensitive variables than Eclipse ever did, and it can pick up all kinds of problems much better than Eclipse, within a few minutes I had fixed the problem and even found a couple of problems that I did not yet know about.</p>
<p style="text-align: center;"><a href="http://www.logaans-site.co.uk/wp-content/uploads/2008/11/netbeans.png"><img class="size-full wp-image-172 aligncenter" title="netbeans" src="http://www.logaans-site.co.uk/wp-content/uploads/2008/11/netbeans.png" alt="" width="500" height="312" /></a></p>
<p>It even includes some basic refactoring tools!</p>
<p>NetBeans does support Unit Testing however there is currently no support for phpUnit at this time. It is planned as a feature some point in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.logaans-site.co.uk/2008/11/12/netbeans-ide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Form Manager</title>
		<link>http://www.logaans-site.co.uk/2008/10/18/form-manager/</link>
		<comments>http://www.logaans-site.co.uk/2008/10/18/form-manager/#comments</comments>
		<pubDate>Sat, 18 Oct 2008 12:34:09 +0000</pubDate>
		<dc:creator>Logaan</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=147</guid>
		<description><![CDATA[I finally found a decent name for this &#8220;DynamicDataModel&#8221; project I have been working on; Form Manager. Synopsis: A set of objects to allow the developer to write as little code as possible to instantly get a form with validated fields and basic data manipulation. My idea to was to write something that would allow me [...]]]></description>
			<content:encoded><![CDATA[<p>I finally found a decent name for this &#8220;DynamicDataModel&#8221; project I have been working on; Form Manager.</p>
<p><em>Synopsis: A set of objects to allow the developer to write as little code as possible to instantly get a form with validated fields and basic data manipulation.</em></p>
<p>My idea to was to write something that would allow me to quickly describe what data I want to edit/display, have a standard mechanism for verify data from the user and a generic method of talking to a database to create/get that data.</p>
<p>So far this is what I have come up with:</p>
<p style="text-align: center;"><a href="http://FileURL"></a></p>
<div id="attachment_148" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.logaans-site.co.uk/wp-content/uploads/2008/10/csharpgened.png"><img class="size-medium wp-image-148  " title="Model" src="http://www.logaans-site.co.uk/wp-content/uploads/2008/10/csharpgened-300x167.png" alt="" width="300" height="167" /></a><p class="wp-caption-text">I built the diagram in NClass, but I kind of cheated and built the model in C# and imported it</p></div>
<p>The modes know how to render the data, where the data needs to come from and at what time.<br />
The fields are quite the opposite, they know where the data is, and what to do with it, but don&#8217;t know when to use it.</p>
<p>So I built this model, the TableDefinition and FieldSet have all the fields hanging off them. And the relevant modes are hanging off the FormManager.</p>
<p>Although I plan to integrate this into phpBB, I have put in layers that should allow for this model to be used in anything.</p>
<p>The other thing is that I am trying to build in as little state as possible so that it can be cached to improve speed. However this will be seen once I start using it in more realistic situations.</p>
<p>The only wierd thing about the model that I am not completely happy with yet is that when the field is told to render itself, it is given the data to use.</p>
<p>I have unit testing around it all, and generated documentation so once its finished I should have quite a nice comprehensive application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.logaans-site.co.uk/2008/10/18/form-manager/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Documenting your code in PHP</title>
		<link>http://www.logaans-site.co.uk/2008/10/09/documenting-your-code-in-php/</link>
		<comments>http://www.logaans-site.co.uk/2008/10/09/documenting-your-code-in-php/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 21:54:27 +0000</pubDate>
		<dc:creator>Logaan</dc:creator>
				<category><![CDATA[Logaan's Toolkit]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=121</guid>
		<description><![CDATA[Whilst working on this model, I found myself forgetting various parameters or names of methods I had created. I can&#8217;t believe how much I rely on an IDE to provide me with all my prompts. I did try setting up Eclipse again with PDT (had tried to use phpEclipse in the past with dissapointing results) [...]]]></description>
			<content:encoded><![CDATA[<p>Whilst working on this model, I found myself forgetting various parameters or names of methods I had created. I can&#8217;t believe how much I rely on an IDE to provide me with all my prompts.</p>
<p>I did try setting up Eclipse again with PDT (had tried to use phpEclipse in the past with dissapointing results) yet I was getting UI errors all over, no matter what I tried (updating the JRE, grabbing various packages) I could not get the thing to work.</p>
<p>So I resorted to the next best thing, I went and found something called <a title="phpDoc" href="http://www.phpdoc.org/" target="_blank">phpDoc</a>. It reads DocBlocks from your code and creates a set of html pages containing all the information about your code.</p>
<p style="text-align: center;"><img class="size-full wp-image-123 aligncenter" title="phpdoc" src="http://www.logaans-site.co.uk/wp-content/uploads/2008/10/phpdoc.jpg" alt="" width="384" height="307" /></p>
<p>Again, I installed it from pear on the command line, there are lots of site out there to help with installing it on Windows. Once installed, you can use the phpdoc -h to get all the command line parameters.</p>
<p>Similar to my last post, I use an msbuild script to run the documentation tasks</p>
<pre class="brush: xml; auto-links: false;">

&lt;Project xmlns=&quot;http://schemas.microsoft.com/developer/msbuild/2003&quot; DefaultTargets=&quot;Build&quot;&gt;

    &lt;PropertyGroup&gt;
        &lt;BuildDir&gt;$(MSBuildProjectDirectory)&lt;/BuildDir&gt;
        &lt;DocumentationTitle&gt;Dynamic Data Model&lt;/DocumentationTitle&gt;
        &lt;HelpOutput&gt;HTML:Smarty:HandS&lt;/HelpOutput&gt;
        &lt;DocumentationFolder&gt;$(BuildDir)Documentation&lt;/DocumentationFolder&gt;
    &lt;/PropertyGroup&gt;

    &lt;ItemGroup&gt;
        &lt;CodeFiles Include=&quot;$(BuildDir)***.php&quot; Exclude=&quot;$(BuildDir)**.svn***.*;
                                 $(BuildDir)**tests***.*&quot; /&gt;
    &lt;/ItemGroup&gt;

    &lt;Target Name=&quot;Clean&quot;&gt;
        &lt;RemoveDir Directories=&quot;$(DocumentationFolder)&quot; Condition=&quot;Exists('$(DocumentationFolder)')&quot; /&gt;
    &lt;/Target&gt;

    &lt;Target Name=&quot;Setup&quot; DependsOnTargets=&quot;Clean&quot;&gt;
        &lt;MakeDir Directories=&quot;$(DocumentationFolder)&quot; Condition=&quot;!Exists('$(DocumentationFolder)')&quot; /&gt;
    &lt;/Target&gt;

    &lt;Target Name=&quot;Build&quot; DependsOnTargets=&quot;Setup&quot;&gt;
        &lt;CallTarget Targets=&quot;BuildDocumentation&quot; /&gt;
    &lt;/Target&gt;

    &lt;Target Name=&quot;BuildDocumentation&quot; DependsOnTargets=&quot;Setup&quot;&gt;
        &lt;CreateProperty Value=&quot;@(CodeFiles, ',')&quot;&gt;
            &lt;Output TaskParameter=&quot;Value&quot; PropertyName=&quot;FilesToDocument&quot; /&gt;
        &lt;/CreateProperty&gt;

        &lt;Exec Command='phpdoc --sourcecode --target &quot;$(DocumentationFolder)&quot; --output $(HelpOutput) --title &quot;$(DocumentationTitle)&quot; --filename $(FilesToDocument)' /&gt;
    &lt;/Target&gt;
&lt;/Project&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.logaans-site.co.uk/2008/10/09/documenting-your-code-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unit testing in PHP with PHPUnit</title>
		<link>http://www.logaans-site.co.uk/2008/09/30/unit-testing-in-php-with-phpunit/</link>
		<comments>http://www.logaans-site.co.uk/2008/09/30/unit-testing-in-php-with-phpunit/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 14:38:45 +0000</pubDate>
		<dc:creator>Logaan</dc:creator>
				<category><![CDATA[Logaan's Toolkit]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.logaans-site.co.uk/2008/09/30/unit-testing-in-php/</guid>
		<description><![CDATA[With this dynamic data model that I am currently building in PHP, I found that for quite a complicated solution I had no unit testing at all. After searching around I found PHPUnit, however, it all hinted at a Linux only environment. A short while later I found a blog that described how to set [...]]]></description>
			<content:encoded><![CDATA[<p>With this dynamic data model that I am currently building in PHP, I found that for quite a complicated solution I had no unit testing at all.</p>
<p>After searching around I found PHPUnit, however, it all hinted at a Linux only environment. A short while later I found a blog that described how to set it up for Windows: <a href="http://usingzendframework.blogspot.com/2007/12/setting-up-phpunit.html">http://usingzendframework.blogspot.com/2007/12/setting-up-phpunit.html</a>. I use Xampp, so I did not have to change the memory limit.</p>
<p>Once installed I used the online pocket guide to start me off: <a href="http://www.phpunit.de/pocket_guide/index.en.php">http://www.phpunit.de/pocket_guide/index.en.php</a></p>
<p>Inside my code folder I created a tests folder where I placed all my php tests, inside that I created an includes folder for all the test related code.</p>
<p><img src="http://www.logaans-site.co.uk/wp-content/uploads/2008/09/folders.jpg" alt="folders.jpg" /></p>
<p>The first thing that the common include does is turn on all the error reporting an strict reporting. This should ensure the most quality coding.</p>
<pre class="brush: php;">
&lt;?php
error_reporting(E_ALL | E_STRICT);
require_once('PHPUnit/Framework.php');
?&gt;
</pre>
<p>Once that is done, I could start with writing all the tests.</p>
<pre class="brush: php;">
&lt;?php
include('includes/common.php');
class ExampleTests extends PHPUnit_Framework_TestCase
{
 public function testSomeObjectTest()
 {
  /* Test code here */
 }
}
?&gt;
</pre>
<p>Once that was done, I created a msbuild script to test them all using the TestSuite class</p>
<pre class="brush: xml;">
&lt;Project xmlns=&quot;http://schemas.microsoft.com/developer/msbuild/2003&quot; DefaultTargets=&quot;Build&quot;&gt;
    &lt;PropertyGroup&gt;
        &lt;BuildDir&gt;$(MSBuildProjectDirectory)&lt;/BuildDir&gt;
    &lt;/PropertyGroup&gt;

    &lt;ItemGroup&gt;
        &lt;CodeFiles Include=&quot;$(BuildDir)***.php&quot; Exclude=&quot;$(BuildDir)**.svn***.*;
                                                           $(BuildDir)**tests***.*&quot; /&gt;
    &lt;/ItemGroup&gt;

    &lt;Target Name=&quot;Build&quot;&gt;
        &lt;CallTarget Targets=&quot;RunTests&quot; /&gt;
    &lt;/Target&gt;

    &lt;Target Name=&quot;RunTests&quot;&gt;
        &lt;Exec Command='phpunit --verbose &quot;$(BuildDir)testsTestSuite.php&quot;' WorkingDirectory=&quot;$(BuildDir)tests&quot; /&gt;
    &lt;/Target&gt;

&lt;/Project&gt;
</pre>
<p>I had to add the framework folder and the php folder onto the PATH environment variable so that I could just call msbuild from the commandline</p>
]]></content:encoded>
			<wfw:commentRss>http://www.logaans-site.co.uk/2008/09/30/unit-testing-in-php-with-phpunit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Data driven pages generated from described data</title>
		<link>http://www.logaans-site.co.uk/2008/05/10/data-driven-pages-generated-from-described-data/</link>
		<comments>http://www.logaans-site.co.uk/2008/05/10/data-driven-pages-generated-from-described-data/#comments</comments>
		<pubDate>Sat, 10 May 2008 12:58:03 +0000</pubDate>
		<dc:creator>Logaan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[phpBB]]></category>

		<guid isPermaLink="false">http://www.logaans-site.co.uk/2008/05/10/data-driven-pages-generated-from-described-data/</guid>
		<description><![CDATA[Over the last couple of projects I have done in php (usually related to phpBB) I always seem to follow the same patterns. List data, edit data, add data&#8230; and every page follows the same pattern; check mode, validate inputs, write to database&#8230; etc etc  So I thought I would look for a framework that would [...]]]></description>
			<content:encoded><![CDATA[<p>Over the last couple of projects I have done in php (usually related to phpBB) I always seem to follow the same patterns. List data, edit data, add data&#8230; and every page follows the same pattern; check mode, validate inputs, write to database&#8230; etc etc</p>
<p> So I thought I would look for a framework that would allow me to describe my data in such a way that it will go off and automatically query the data, join data from lookups, check data inputs, update the database and generate all the pages and forms for me.</p>
<p>Alas I did not find any such projects on the internet (so I am going to have a crack at it myself) but I did find this project: <a href="https://www.projectzero.org/">https://www.projectzero.org/</a></p>
<p>Its a bit over developed for what I want to achieve, still sounds pretty neat.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.logaans-site.co.uk/2008/05/10/data-driven-pages-generated-from-described-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
