<?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; propel</title>
	<atom:link href="http://codepoets.co.uk/tag/propel/feed/" rel="self" type="application/rss+xml" />
	<link>http://codepoets.co.uk</link>
	<description>PHP, running, family stuff, Bromsgrove and other bits</description>
	<lastBuildDate>Tue, 24 Jan 2012 11:20:53 +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>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 <a class="read-excerpt" href="http://codepoets.co.uk/2010/random-php-project-progress/">Continue reading <span class="meta-nav">&#187;</span></a>]]></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 &#8216;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>
	</channel>
</rss>

