<?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>Giv Parvaneh &#187; PHP</title>
	<atom:link href="http://www.givp.org/blog/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.givp.org/blog</link>
	<description>::::..::..:::::::...:::::....::......:::::::::....::::......::::::::::::::::</description>
	<lastBuildDate>Mon, 23 Jan 2012 17:50:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<meta xmlns="http://www.w3.org/1999/xhtml" name="robots" content="noindex,follow" />
		<item>
		<title>Zend Framework + MongoDB + Morph</title>
		<link>http://www.givp.org/blog/2011/02/26/zend-framework-mongodb-morph/</link>
		<comments>http://www.givp.org/blog/2011/02/26/zend-framework-mongodb-morph/#comments</comments>
		<pubDate>Sat, 26 Feb 2011 20:57:56 +0000</pubDate>
		<dc:creator>Giv</dc:creator>
				<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[mongoDB]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://www.givp.org/blog/?p=253</guid>
		<description><![CDATA[This is not another SQL vs noSQL rant. I&#8217;m not here to defend one or the other and there are plenty of articles written about this very topic. I just wanted to share my personal experience with using MongoDB in Zend Framework using the Morph library. The most painful part of programming for me is [...]]]></description>
			<content:encoded><![CDATA[<p>This is not another SQL vs noSQL rant. I&#8217;m not here to defend one or the other and there are plenty of articles written about this very topic. I just wanted to share my personal experience with using <a href="http://www.mongodb.org/" onclick="pageTracker._trackPageview('/outgoing/www.mongodb.org/?referer=');">MongoDB</a> in <a href="http://framework.zend.com/" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/?referer=');">Zend Framework</a> using the <a href="http://code.google.com/p/mongodb-morph/" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/mongodb-morph/?referer=');">Morph</a> library. </p>
<p>The most painful part of programming for me is the CRUD of persistant data storage. I can&#8217;t think of anything more tedious than creating complex SQL schemas, modelling my data, creating getters and setters etc. I know what data I need to store, retrieve and manipulate and I just want to dive into the code without having to waste hours setting up the database. But the real pain starts during iterations where I have to update the schema and deploy the changes to all environments &#8211; or worse, roll back schema changes.</p>
<p>After discovering <a href="http://www.djangoproject.com/" onclick="pageTracker._trackPageview('/outgoing/www.djangoproject.com/?referer=');">Django</a>&#8216;s modelling layer I realised what I was missing out on. It made perfect sense to me. Make your models first and have the SQL managed by the framework automatically. Of course this was still quite annoying because model/schema changes were quite difficult to do but at least there was no need for CRUD because you get it all for free. No more complex join queries!</p>
<p>Once I started using <a href="http://code.google.com/appengine/" onclick="pageTracker._trackPageview('/outgoing/code.google.com/appengine/?referer=');">Google App Engine</a>&#8216;s <a href="http://code.google.com/appengine/docs/python/datastore/" onclick="pageTracker._trackPageview('/outgoing/code.google.com/appengine/docs/python/datastore/?referer=');">Datastore</a> I was free of SQL&#8217;s constraints. I created my data models and if I needed to add an extra field to my model I could do so without having to worry about running ALTER TABLE commands.</p>
<p>I&#8217;ve spent the last 2 years working with another noSQL system, <a href="http://couchdb.apache.org/" onclick="pageTracker._trackPageview('/outgoing/couchdb.apache.org/?referer=');">CouchDB</a> and again, I&#8217;m not here to compare the two but MongoDB just seems more suitable for my needs. I have now integrated MongoDB into my Zend Framework projects and it&#8217;s hard to imagine how I ever lived without it. It&#8217;s ridiculously easy to set up, no CRUD and it&#8217;s incredibly intuitive. Here&#8217;s how:</p>
<p>1. <a href="http://www.mongodb.org/downloads" onclick="pageTracker._trackPageview('/outgoing/www.mongodb.org/downloads?referer=');">Download</a> and run MongoDB service<br />
Once you have downloaded the binaries, create a directory where you want your data stored. Remember MongoDB creates individual BSON (binary JSON) documents for each record. You can start the service by running:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">shell<span style="color: #000000; font-weight: bold;">&gt;</span> mongod <span style="color: #660033;">--dbpath</span>=<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>my<span style="color: #000000; font-weight: bold;">/</span>mongodata</pre></div></div>

<p>2. Install the <a href="http://php.net/manual/en/mongo.installation.php" onclick="pageTracker._trackPageview('/outgoing/php.net/manual/en/mongo.installation.php?referer=');">MongoDB PHP extension</a><br />
After downloading the extension install and add to your php.ini</p>
<p>3. Download the <a href="http://code.google.com/p/mongodb-morph/downloads/list" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/mongodb-morph/downloads/list?referer=');">Morph library</a><br />
 Add the Morph lib to your PHP include path (or autoload in ZF)</p>
<p>You are ready to go. Let&#8217;s try and use it in a simple ZF project. Let&#8217;s say we want to create a shopping cart that holds a product name, quantity, price and colour.</p>
<p>Create a &#8220;Cart.php&#8221; class in /models directory and extend Morph_Object.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Application_Model_Cart <span style="color: #000000; font-weight: bold;">extends</span> Morph_Object
<span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>      
        parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addProperty</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Morph_Property_String<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
             <span style="color: #339933;">-&gt;</span><span style="color: #004000;">addProperty</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Morph_Property_Integer<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'quantity'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
             <span style="color: #339933;">-&gt;</span><span style="color: #004000;">addProperty</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Morph_Property_Float<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'price'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
             <span style="color: #339933;">-&gt;</span><span style="color: #004000;">addProperty</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Morph_Property_String<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'colour'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>     
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Believe it or not, you&#8217;ve just finished modelling your data and CRUD and you&#8217;re ready to store and retrieve data immediately without having to run any SQL generation scripts. Brilliant.</p>
<p>To store data in say a controller, you would do something like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// instantiate mongo and select your db</span>
<span style="color: #000088;">$mongo</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Mongo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Morph_Storage<span style="color: #339933;">::</span><span style="color: #004000;">init</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mongo</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">selectDB</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'shoppingDB'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// instantiate your cart        </span>
<span style="color: #000088;">$cart</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Application_Model_Cart<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// add data</span>
<span style="color: #000088;">$car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Something cool'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$cart</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">quantity</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">12</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$cart</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">price</span> <span style="color: #339933;">=</span> <span style="color:#800080;">15.50</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$cart</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">color</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Red&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// save the data</span>
<span style="color: #000088;">$cart</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>You&#8217;ve just saved your first record and didn&#8217;t have to create individual getters and setters for your fields.</p>
<p>Getting the data out is just as simple:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// instantiate mongo and select your db</span>
<span style="color: #000088;">$mongo</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Mongo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Morph_Storage<span style="color: #339933;">::</span><span style="color: #004000;">init</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mongo</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">selectDB</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'shoppingDB'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// instantiate your cart        </span>
<span style="color: #000088;">$cart</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Application_Model_Cart<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// create a query</span>
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Morph_Query<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">property</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'price'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">greaterThan</span><span style="color: #009900;">&#40;</span><span style="color:#800080;">1.0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// find records matching query</span>
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cart</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">findByQuery</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// send results down to view layer        </span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$result</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Check the documentation for the full list of query options. Now loop through the results in your view layer and output the data:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">result</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;li&gt;<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/li&gt;
<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">endforeach</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>The best part is that since our data store is schema-less, you are free to manipulate your data structure like adding a new field. You do this by simply adding a new property to the Cart class. That&#8217;s it.</p>
<p>I hope this post demonstrates the benefits of using noSQL in your PHP projects. Naturally you can use the above in any PHP framework. I just used ZF as an example.</p>
<p>Happy noSQL coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.givp.org/blog/2011/02/26/zend-framework-mongodb-morph/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Test-driven Development in Agile Projects</title>
		<link>http://www.givp.org/blog/2009/11/21/test-driven-development-in-agile/</link>
		<comments>http://www.givp.org/blog/2009/11/21/test-driven-development-in-agile/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 14:29:06 +0000</pubDate>
		<dc:creator>Giv</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.givp.org/blog/?p=113</guid>
		<description><![CDATA[I recently posted this on the BBC Web Developer Blog: http://www.bbc.co.uk/blogs/webdeveloper/2009/11/testdriven-development-in-agil.shtml Developers at the BBC tend to use Agile methodologies as a way to quickly release iterations of products. But where does rigorous code testing fit in with the short development and release cycles? How can we maintain the quality of our code when things [...]]]></description>
			<content:encoded><![CDATA[<p>I recently posted this on the BBC Web Developer Blog:</p>
<p><a href="http://www.bbc.co.uk/blogs/webdeveloper/2009/11/testdriven-development-in-agil.shtml" onclick="pageTracker._trackPageview('/outgoing/www.bbc.co.uk/blogs/webdeveloper/2009/11/testdriven-development-in-agil.shtml?referer=');">http://www.bbc.co.uk/blogs/webdeveloper/2009/11/testdriven-development-in-agil.shtml</a></p>
<blockquote><p>
Developers at the BBC tend to use Agile methodologies as a way to quickly release iterations of products. But where does rigorous code testing fit in with the short development and release cycles? How can we maintain the quality of our code when things need to change so fast?
</p></blockquote>
<p><a href="http://www.bbc.co.uk/blogs/webdeveloper/2009/11/testdriven-development-in-agil.shtml" onclick="pageTracker._trackPageview('/outgoing/www.bbc.co.uk/blogs/webdeveloper/2009/11/testdriven-development-in-agil.shtml?referer=');">More</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.givp.org/blog/2009/11/21/test-driven-development-in-agile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML Scraping &#8211; Python vs PHP (re-post)</title>
		<link>http://www.givp.org/blog/2009/10/26/html-scraping-python-vs-php/</link>
		<comments>http://www.givp.org/blog/2009/10/26/html-scraping-python-vs-php/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 21:11:19 +0000</pubDate>
		<dc:creator>Giv</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.givp.org/blog/?p=81</guid>
		<description><![CDATA[I posted this last year on my old blog. The subject came up again today so I dug it up from the archives: I usually hate these &#8220;X vs Y&#8221; discussions but this week I was working on a harvesting project and was trying to figure out whether I should go down the Python or [...]]]></description>
			<content:encoded><![CDATA[<p>I posted this last year on my old blog. The subject came up again today so I dug it up from the archives:</p>
<p>I usually hate these &#8220;X vs Y&#8221; discussions but this week I was working on a harvesting project and was trying to figure out whether I should go down the Python or PHP route. I have been using PHP for many years now so PHP was the obvious choice but recently I have been using Python a fair bit and the more I use it, the more I realise what a sloppy language PHP is.</p>
<p>So I set out to do some tests to see which would get my task done quicker.</p>
<p>For Python I used the <a href="http://www.crummy.com/software/BeautifulSoup/" onclick="pageTracker._trackPageview('/outgoing/www.crummy.com/software/BeautifulSoup/?referer=');">Beautiful Soup</a> module and for PHP I used <a href="http://simplehtmldom.sourceforge.net/" onclick="pageTracker._trackPageview('/outgoing/simplehtmldom.sourceforge.net/?referer=');">PHP Simple HTML DOM Parser</a> class.</p>
<p><strong>The test:</strong><br />
<em>Go to http://news.bbc.co.uk, look for the third &lt;p&gt; tag and return the text for the first link within that paragraph.</em></p>
<p>Both classes make this very easy to do so coding was not a concern:</p>
<p><strong>in Python:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">page = <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;http://news.bbc.co.uk&quot;</span><span style="color: black;">&#41;</span>
soup = BeautifulSoup<span style="color: black;">&#40;</span>page<span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> soup.<span style="color: black;">findAll</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'p'</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>.<span style="color: black;">findAll</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'a'</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>.<span style="color: #dc143c;">string</span></pre></td></tr></table></div>

<p><strong>in PHP:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> file_get_html<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://news.bbc.co.uk'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'p'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'a'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">innertext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>I ran each 5 times to measure the execution time.</p>
<p><strong>Python:</strong><br />
0.622022151947 seconds<br />
0.577415943146 seconds<br />
0.518396139145 seconds<br />
0.503247022629 seconds<br />
0.482849121094 seconds</p>
<p><strong>PHP:</strong><br />
0.430239915848 seconds<br />
0.415632009506 seconds<br />
0.408473014832 seconds<br />
0.413187026978 seconds<br />
0.411664962769 seconds</p>
<p>Pretty damn close but PHP is on average a bit faster it seems.</p>
<p>To be fair, this really isn&#8217;t a very good way to measure the performance of the two. The real test, in my opinion, would be to see how scalable each method is and how they handle memory management once I start scraping say the entire Wikipedia collection. I could be wrong here but from what I&#8217;ve read so far, Python is the tool of choice for such heavy processing tasks.</p>
<p>Either way, I think I&#8217;ll go with Python <img src='http://www.givp.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.givp.org/blog/2009/10/26/html-scraping-python-vs-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  www.givp.org/blog/category/php/feed/ ) in 1.02653 seconds, on Feb 4th, 2012 at 4:18 am UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 4th, 2012 at 5:18 am UTC -->
