<?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>David Goodwin &#187; php</title>
	<atom:link href="http://codepoets.co.uk/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://codepoets.co.uk</link>
	<description>PHP, running, family stuff, Bromsgrove and other bits</description>
	<lastBuildDate>Thu, 29 Jul 2010 10:50:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Still looking for a PHP contractor&#8230;.</title>
		<link>http://codepoets.co.uk/2010/still-looking-for-a-php-contractor/</link>
		<comments>http://codepoets.co.uk/2010/still-looking-for-a-php-contractor/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 20:40:07 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[contractor]]></category>
		<category><![CDATA[interview]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=112</guid>
		<description><![CDATA[At work I&#8217;m still looking for a short term PHP contractor. Perhaps I&#8217;m being unrealistic in my expectations/requirements (rate/location/duration/skills etc), but nevertheless&#8230;. As I&#8217;ve not found anyone via normal channels (twitter/phpwm user group etc) I thought I&#8217;d turn to a random recruitment agency (who I&#8217;d spoken to a week or so ago).
Yesterday I interviewed one [...]]]></description>
			<content:encoded><![CDATA[<p>At <a title="Pale Purple PHP development" href="http://www.palepurple.co.uk">work</a> I&#8217;m still looking for a short term PHP contractor. Perhaps I&#8217;m being unrealistic in my expectations/requirements (rate/location/duration/skills etc), but nevertheless&#8230;. As I&#8217;ve not found anyone via normal channels (twitter/<a title="PHP user group" href="http://phpwm.org">phpwm</a> user group etc) I thought I&#8217;d turn to a random recruitment agency (who I&#8217;d spoken to a week or so ago).</p>
<p>Yesterday I interviewed one guy &#8211; who&#8217;d been a programmer for a number of years (10+) &#8211; using Visual Foxpro (whatever that is) &#8211; presumably it&#8217;s a dead language, as he wants to move across into <a title="PHP" href="http://php.net">PHP</a>. He has very basic PHP experience (yet claims 2 years on his CV), figured out how to do FizzBuzz and Recursion without too much help &#8211; but didn&#8217;t know anything about object orientation, separation of concerns (specifically <a title="Model View Controller - Wikipedia" href="http://en.wikipedia.org/wiki/Model–view–controller">MVC</a>), security (obvious SQL injection) or unit testing and failed to make any comment on what is almost the worst code I could find to present to him. This isn&#8217;t necessarily a problem &#8211; I would normally be happy to train someone &#8211; however, not when I&#8217;m paying him £25/hour and I&#8217;d be lucky if he was productive within a week. (Hint: students are better than this when they&#8217;ve only been in <a title="Computer Science - Aberystwyth" href="http://www.aber.ac.uk/compsci">University</a> for two years).</p>
<p>Today, I therefore continued hunting, with mixed success. I had three more CVs &#8211; all asking for more money, and one looked quite good &#8211; but had a requirement he worked remotely after the first few days (well he does live in Telford). Another, who is local, I&#8217;m interviewing tomorrow. Wanting to do some homework on him, I had a look at a couple of websites mentioned in his doctored CV  - the first is clearly .Net from the error message it throws when you pass a &gt; into it&#8217;s search box &#8211; so either they replaced his PHP site quickly or his CV is misleading. The <a title="ladyflamingo" href="http://www.ladyflamingo.info/ladytalk/">second has a PHP error</a> on it &#8211; and is only (effectively) a themed <a title="wordpress" href="http://wordpress.org">wordpress</a> site which looks like it&#8217;s slowly rotting. From these I found out his address (hint: whois $flamingodomain) and an invalid email address/domain (which archive.org seems to not do much with). Typing in his name into Google / LinkedIn, Facebook etc produces no obvious matches. So I know hardly anything about him, and for all intent he may as well not exist. Great sales job there.</p>
<p>From talking to the recruiters it seems it&#8217;s difficult to find decent PHP programmers &#8211; and anyone who may be decent will almost certainly not be programming PHP as their primary language (i.e. they&#8217;ll be doing web development in Java/.Net, and know PHP quite well). This seems a shame, but really only confirms what I already knew from interacting with others in the community. I&#8217;ve known for ages that I&#8217;ve effectively taken a large pay cut by running my own company, and doing PHP. It sucks that this continues to be the case. Clearly I&#8217;m a martyr or something.</p>
<p>So, if you happen to be a contractor looking for work, please make an effort. I&#8217;m not overly impressed so far, and may just end up stalling customers for another week/month instead.</p>
<p>(Oddly I wrote this post, posted it, and it vanished. What are you up to wordpress? Why do you want me to retype things in twice?)</p>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2010/still-looking-for-a-php-contractor/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Random PHP project progress</title>
		<link>http://codepoets.co.uk/2010/random-php-project-progress/</link>
		<comments>http://codepoets.co.uk/2010/random-php-project-progress/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 22:03:40 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[pdo]]></category>
		<category><![CDATA[propel]]></category>
		<category><![CDATA[simpletest]]></category>
		<category><![CDATA[smarty]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[unit testing]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=99</guid>
		<description><![CDATA[Random php development musing]]></description>
			<content:encoded><![CDATA[<p>Initially when we founded <a title="Pale Purple PHP web development" href="http://www.palepurple.co.uk">Pale Purple</a> all our new <a title="PHP" href="http://php.net">PHP</a> development used a combination of <a title="Propel" href="http://propel.phpdb.org">Propel</a>, <a title="Smarty" href="http://smarty.net">Smarty</a> and some inhouse glue. Over time we seem to have drifted towards the <a title="Zend Framework" href="http://framework.zend.com">Zend Framework</a>, but I&#8217;ve never been particularly happy with Zend_Db or Zend_View. Why the Zend Framework? Well, it has loads of useful components (Cache, Form, Routing, Mail etc) and it&#8217;s near enough an industry standard from what we see &#8211; and obviously I&#8217;d rather build on the shoulders of others than spend time developing an in-house framework no one else will ever use.</p>
<p>For one customer, we&#8217;re currently working on the next iteration of their code base &#8211; which incorporates a number of significant changes. When we inherited the code base from the previous developers we spent a long time patching various SQL Injection holes (casting to ints), moving over to use PDO&#8217;s prepared statements and trying to keep on top of the customer&#8217;s new functionality requests and support issues. There&#8217;s still a lot of horrible code to refactor, plenty of security holes (although none public facing) and we know we&#8217;re moving in the right direction &#8211; hopefully patching and duct tape will soon be a thing of the past as it will develop some form of architecture and look like someone has thought about design and long term maintenance.</p>
<p>I&#8217;ve started to properly do Test First Development &#8211; at least from a support perspective &#8211; as too often we&#8217;d find we would patch a bug, only for it to reappear again in a few weeks/months time. This has been especially useful with the SOAP interface the application exposes. The tests run every 5 minutes, and we all get emailed when stuff breaks &#8211; it took all of 30 minutes to setup and put in place &#8211; then it was just a case of actually writing the unit tests themselves (the tests take minutes to write; finding/fixing any bugs they pin point takes somewhat longer :-/ ). I&#8217;ve also abused Simpletest&#8217;s web testing &#8217;stuff&#8217; to also act as an availability checker of the live site (i.e. hit a few remote URLs, and check that we don&#8217;t get error messages back and do see expected strings).</p>
<p>The original code base had no &#8216;model&#8217; like layer (or MVC &#8216;compliance&#8217;) &#8211; files containing HTML, CSS, SQL, Javascript and PHP were the norm &#8211; we&#8217;ve added Propel to the project as the &#8216;model&#8217; layer &#8211; which took a few hours; and then when reverse engineering the database we found a few oddities (tables without primary keys and so on) &#8211; anyway, moving the functionality from a handful of legacy objects across into the Propel ones seems to be well underway, and I for one will be glad to see the end of :</p>
<pre>$x = new Foo(5);</pre>
<p>Accompanied with code that does the equivalent of :</p>
<pre>class Foo {</pre>
<pre>    public function __construct($id = false) {</pre>
<pre>        if($id != false) {</pre>
<pre>            // select * from foo where id = 5</pre>
<pre>            // populate $this; don't bother checking for the edge case where $id isn't valid</pre>
<pre>       }</pre>
<pre>       else {</pre>
<pre>           // insert into foo values ('');</pre>
<pre>          // populate $this-&gt;id; leaving all other fields as empty strings...</pre>
<pre>     }</pre>
<pre>     public function setBaz($nv) { // repeat for all table fields</pre>
<pre>         $this-&gt;baz = $nv;</pre>
<pre>         global $db;</pre>
<pre>         $db-&gt;query('update foo set baz = "' . $nv . '" where id = ' . $this-&gt;id);</pre>
<pre>     }</pre>
<pre>}</pre>
<pre></pre>
<p>Finally, we have a meaningful directory structure &#8211; where some things aren&#8217;t exposed in the document root. Hopefully soon a front controller and some decent routing. At the moment a huge amount of code is just sat in the &#8216;public&#8217; directory due to it&#8217;s nature. We hope to fix this in time, and move to using Zend Controller &#8211; once we get Smarty integrated with it.</p>
<p>Propel has added some nice new features since we last used it (effectively v1.2); it was a toss up between it and Doctrine (as obviously the ZF is moving in that direction) &#8211; but we already had knowledge/experience with Propel and it seemed the easier option.</p>
<p>I&#8217;m hoping that with time we&#8217;ll be able to get up to at least 60% test coverage of the code base &#8211; at that point we should be able to refactor the code far easier and with less fear. At the moment I doubt the unit tests cover more than 5-10% &#8211; although maybe it&#8217;s time I pointed xdebug or whatever at it to generate some meaningful stats.</p>
<p>My final task is to get some decent performance measurements out of the code base &#8211; so we can track any performance regressions. I&#8217;m fairly confident that moving to Propel will result in an speedup as duplicate object hydrations will be eliminated thanks to it&#8217;s instance pool, however having hard figures and nice graphs to point at would be ideal. So far I&#8217;ve knocked up my own script around &#8216;ab&#8217; which stores some figures to a .csv file and uses ezComponents to generate a graph file. This seems to be a crap solution, but I can&#8217;t think or find anything better. Any suggestions dear Internet? Perhaps I should integrate changeset/revision id&#8217;s in my benchmarking too. Suggestions here would be exceedingly appreciated.</p>
<p>There, I should have ticked all necessary boxes wrt development practices now. Now to work on finding a contract PHP developer&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2010/random-php-project-progress/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP array and object addition and string indexing</title>
		<link>http://codepoets.co.uk/2009/php-arrays-objects-addition-and-string-indexing/</link>
		<comments>http://codepoets.co.uk/2009/php-arrays-objects-addition-and-string-indexing/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 09:08:21 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=49</guid>
		<description><![CDATA[While reading someone&#8217;s code, I came across the following sort of thing:

function foo($config = array()) {
 $this-&#62;_config += $config;
//...
}

To which I thought WTF? How does PHP cast an array to a number to perform addition?
A few random tests later, it appears PHP joins the two arrays together, only adding indexes that appear in the second [...]]]></description>
			<content:encoded><![CDATA[<p>While reading someone&#8217;s code, I came across the following sort of thing:</p>
<p><code><br />
function foo($config = array()) {</code></p>
<p><code> $this-&gt;_config += $config;<br />
//...<br />
}<br />
</code></p>
<p>To which I thought WTF? How does PHP cast an array to a number to perform addition?</p>
<p>A few random tests later, it appears PHP joins the two arrays together, only adding indexes that appear in the second (and not first) array.</p>
<p>(as per <a href="http://php.net/manual/en/language.operators.array.php">php manual &#8211; array operators</a>)</p>
<p>Namely :</p>
<p>$array_1 = array(&#8216;a&#8217;,'b&#8217;, 4=&gt;&#8217;c');<br />
$array_2 = array(4=&gt;&#8217;e', &#8216;f&#8217;, &#8216;g&#8217;);</p>
<p>$array_1 += $array_2;</p>
<p>print_r($array_1);</p>
<p>will give :<br />
Array<br />
(<br />
[0] =&gt; a<br />
[1] =&gt; b<br />
[4] =&gt; c<br />
[5] =&gt; f<br />
[6] =&gt; g<br />
)</p>
<p>(Note; 4=&gt;e is not in the resultant array, because 4=&gt;c was in array_1).</p>
<p>After a round about conversation with Moobert on this on IRC &#8211; at which point he probably put me out of my misery, he also gave me the following :</p>
<p>$x = &#8216;test&#8217;;<br />
echo $x['whatever']; // outputs &#8216;t&#8217;</p>
<p>Which I can understand &#8211; as PHP allows for per-character access to a string (based on position) &#8211; hence &#8217;something&#8217; gets casted to zero, and we get the first character back.</p>
<p>I know I can cast objects to arrays, and vice versa.</p>
<p>Seemingly Objects don&#8217;t follow any sort of &#8216;union&#8217; rule however&#8230; as adding two objects results in &#8216;2&#8242;. Not sure how PHP converts an object into &#8216;1&#8242;&#8230; but there we are. I sort of expected to get an object back (assuming the inputs were the same type) with a union of properties, but no.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2009/php-arrays-objects-addition-and-string-indexing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
