<?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>{ Online Notes } &#187; php</title>
	<atom:link href="http://www.armando.ws/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.armando.ws</link>
	<description>All things Technical and Personal - Armando Padilla</description>
	<lastBuildDate>Sat, 12 Jun 2010 05:06:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Zend_Service_Netflix Release 1 Available.</title>
		<link>http://www.armando.ws/2008/11/zend_service_netflix-release-1-available/</link>
		<comments>http://www.armando.ws/2008/11/zend_service_netflix-release-1-available/#comments</comments>
		<pubDate>Sat, 22 Nov 2008 22:40:35 +0000</pubDate>
		<dc:creator>Armando Padilla</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[netflix]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.armando.ws/?p=257</guid>
		<description><![CDATA[So about a month after initially starting on the code, I finally released two versions of the Zend_Service_Netflix wrapper for the Zend Framework, submitted a proposal to the Zend Framework Team, and changed the status on my proposal from &#8220;New&#8221; to &#8220;Ready for Review&#8221;.  Pheww was that hard work put to good use.  It feels [...]]]></description>
			<content:encoded><![CDATA[<p>So about a month after initially starting on the code, I finally released two versions of the Zend_Service_Netflix wrapper for the Zend Framework, submitted a proposal to the Zend Framework Team, and changed the status on <a href="http://framework.zend.com/wiki/display/ZFPROP/Zend_Service_Netflix-Armando+Padilla" target="_blank">my proposal</a> from &#8220;New&#8221; to &#8220;Ready for Review&#8221;.  Pheww was that hard work put to good use.  It feels good to get this off and running with the initial release.</p>
<p><strong>What&#8217;s included in the release?</strong><br />
Like I mentioned before i created 2 releases.  One release contains only the catalog functionality.  It allows developers to use title search, title auto complete which can be used in conjunction with AJAX to create a autocomplete search box, retrieve detailed title information, and search actors/directors.  This package is intended for developers that want to use the extensive Netflix catalog on their own web site without the added functionality found in the full version of the release.</p>
<p>The second release, the FULL release, contains not only the catalog functionality but also allows developers to manage user queues, manage user ratings, retrieve user reviews, and most importantly create the request access url, the URL which users NEED to click that allows their app to retrieve restricted content.  So if the developer wanted to create a Zend Framework powered app that allowed users to add, delete, and update their &#8220;Watch Queue&#8221; or &#8220;Instant Watch Queue&#8221; they can do this by calling a simple method within this package.</p>
<p><strong>Where can i get the release?</strong><br />
I committed the releases to the Google Code site Located here, <a href="http://code.google.com/p/zendframeworknetflixservice/downloads/list" target="_blank">Zend Framework Netflix</a>.  The packages are properly named so you wont have trouble distinguishing which one you need.</p>
<p><strong>Whats next?<br />
</strong>The next steps for this project is to have the Zend Framework team review some of the code, my submitted outline, and hopefully approve it.  On my end I will continue to work on the code.  There are 2 items which i need to iron out, Updating Ratings, Deleting an Item from the users Queue, and updating the code to support the SIGNITURE METHOD HMAC-SHA1.  I will place these items and other &#8220;gotchas&#8221; on the google code twiki to continue to track my progress.  I will also clean up my PHPUnit tests.</p>
<p>I would like to also create a small set of examples for the user to refer to, as well as a small application users can see the code in use. Again i will provide the details on the google code twiki and here as well.</p>
<p>I&#8217;m anxious to hear back from anyone that&#8217;s using it how i can improve on it and what they think is a better approach.</p>
<p>Armando Padilla</p>
<p><strong>Links of interest?  Maybe?</strong></p>
<ul>
<li><a href="http://framework.zend.com/wiki/display/ZFPROP/Zend_Service_Netflix-Armando+Padilla" target="_blank">Zend Proposal &#8211; has examples you can use to run the code under &#8220;Use cases&#8221;.</a></li>
<li><a href="http://code.google.com/p/zendframeworknetflixservice/" target="_blank">Zend Framework Netflix Service Google Code Twiki.</a></li>
<li><a href="http://code.google.com/p/zendframeworknetflixservice/downloads/list" target="_blank">Zend Framework Netflix Service Download Page.</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.armando.ws/2008/11/zend_service_netflix-release-1-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework &amp; Netflix &#8211; Zend_Service_Netflix</title>
		<link>http://www.armando.ws/2008/10/zend-framework-and-netflix-zend_service_netflix/</link>
		<comments>http://www.armando.ws/2008/10/zend-framework-and-netflix-zend_service_netflix/#comments</comments>
		<pubDate>Fri, 10 Oct 2008 08:24:14 +0000</pubDate>
		<dc:creator>Armando Padilla</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[netflix]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[zend_service_netflix]]></category>

		<guid isPermaLink="false">http://www.armando.ws/?p=255</guid>
		<description><![CDATA[I popped on the headphones, slipped a Thievery Corporation track and started to read the new Netflix REST API. A few hours later and a mad rush to code, I created a pre-pre-pre-pre-alpha release package for the Zend Framework.  It&#8217;s a rough implementation that has much to be done to it and has not been [...]]]></description>
			<content:encoded><![CDATA[<p>I popped on the headphones, slipped a <a href="http://www.imeem.com/nataliewalker/music/NZR8oXug/natalie_walker_quicksand_thievery_corporation_remix/" target="_blank">Thievery Corporation track</a> and started to read the new Netflix REST API. A few hours later and a mad rush to code, I created a pre-pre-pre-pre-alpha release package for the Zend Framework.  It&#8217;s a rough implementation that has much to be done to it and has not been flushed out that well. It currently supports only one REST call, &#8220;/catalog/title&#8221;, but I have plans to support the entire gambit of REST calls open by Netflix for this package.</p>
<p>For those interested in the <a href="http://developer.netflix.com/page">netflix api check this page out</a>.  It&#8217;s basically the netflix documentation. Its pretty straight-forward and should be an easy and fun read.  I was surprised they opened up their &#8216;predicted rating&#8217; api. Nice touch <img src='http://www.armando.ws/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  I can see A LOT of things developers can do with just the prediction REST api.</p>
<p>And for those that want to check out the Zend_Service_Netflix code i currently have, here is the <a href="http://code.google.com/p/zendframeworknetflixservice/">Google Code Project Page</a> link.  </p>
<p>I plan to finish the package by Sunday evening.  Here is my attack plan.</p>
<p><strong>Attack Plan:</strong></p>
<ol>
<li>Finish the concrete classes. (ETA Friday evening) </li>
<li>Finish Up the remaining REST calls (ETA Saturday Evening)</li>
<li>Create test using PHPUnit. (ETA. as I go)</li>
<li>Documentation.  (ETA Sunday evening) </li>
</ol>
<div><strong>Links:</strong><br />
<a href="http://code.google.com/p/zendframeworknetflixservice/" target="_blank">Zend Service Nerflix download package</a> (my version)</div>
<div><a href="http://developer.netflix.com/page" target="_blank">Netflix API URL</a></div>
<div><a href="http://framework.zend.com/" target="_blank">Zend Framework URL </a> <br />
 </div>
<div>Ok so its like almost 2am and spent all evening reading and coding ill have move updates tomorrow evening.</div>
<div>
<p>Armando Padilla<br />
PS.  Yes i know, the code looks like ass..sue me (no don&#8217;t that would suck) I did all that in a few (3) hours. </p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.armando.ws/2008/10/zend-framework-and-netflix-zend_service_netflix/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Zend_Paginator and Your Result Set.</title>
		<link>http://www.armando.ws/2008/10/zend_paginator-and-your-result-set/</link>
		<comments>http://www.armando.ws/2008/10/zend_paginator-and-your-result-set/#comments</comments>
		<pubDate>Sun, 05 Oct 2008 07:15:02 +0000</pubDate>
		<dc:creator>Armando Padilla</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Pagination]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Zend_Db]]></category>
		<category><![CDATA[Zend_Db_Select]]></category>
		<category><![CDATA[Zend_Paginator]]></category>

		<guid isPermaLink="false">http://www.armando.ws/?p=254</guid>
		<description><![CDATA[The day was cloudy, it rained last night (i love rain), so it placed me into one of those, &#8220;damn about time&#8221;, moods.  Then I popped open Chrome and came to one of my usual stomping grounds on the net.  I clicked on the thread. Read how a few people were having an issue I [...]]]></description>
			<content:encoded><![CDATA[<p>The day was cloudy, it rained last night (i love rain), so it placed me into one of those, &#8220;damn about time&#8221;, moods.  Then I popped open Chrome and came to one of my usual stomping grounds on the net.  I clicked on the thread. Read how a few people were having an issue I grappled with earlier when dealing with Zend_Paginator and decided to write. The issue, How to use the Zend_Paginator on a database result set without having to fetch ALL of the records.</p>
<p><strong>What is the Pagination?  </strong><br />
A bit of an intro. What&#8217;s Pagination.  Pagination is simply a way in which developers allow users visiting a site to scroll through a long list of records be it 10 at at time, 100 at a time, or &lt;your arbitrary number here&gt; at a time.  Im sure you&#8217;ve seen it around the web but might not have called it by the fancy-smancy &#8220;Pagination&#8221; name.  Hell I call it, &#8220;that next and previous button thinggie&#8221;, or &#8220;that 1 2 3 4 5 page selector stuff&#8221;.  Lets continue. </p>
<p>Pagination used to be an tedious but necessary task for developers.  I wont go into al the steps to create your own custom pagination code base but let me just tell you it sucked. Thank you Zend_Paginator for less stress in my life.</p>
<p><strong>Zend_Paginator a public service announcement.</strong><br />
In its newest installment, Zend Framework 1.6, the developers at Zend added in a pagination component, Zend_Paginator.  This allowed developers like you and me to create Pagination features on the fly (it took me 1 minute to implement when i timed it)  Lets take a quick example.</p>
<p>&lt;?php<br />
require_once &#8220;Zend/Loader.php&#8221;;<br />
Zend_Loader::loadClass(&#8221;Zend_Paginator&#8221;);</p>
<p>//Intialize records.  This is what th user will paginate through.<br />
$myRecords = array(&#8221;Armando Padilla&#8221;,<br />
&#8220;Monica R.&#8221;,<br />
&#8220;Elisa P.&#8221;,<br />
&#8220;Francisca P.&#8221;,<br />
&#8220;Guillermo P.&#8221;,<br />
&#8220;Some awesome person in my family&#8221;);</p>
<p>//Create Paginator Object<br />
$Paginator = Zend_Paginator::factory($myRecords);</p>
<p>//Set the current page were on.<br />
$Paginator-&gt;setCurrentPageNumber($currentPage);</p>
<p>//Set the number of records to show per page<br />
$Paginator-&gt;setItemCountPerPage(3);</p>
<p>//Save Paginator as View var.<br />
$this-&gt;view-&gt;paginator = $Paginator;<br />
?&gt;</p>
<p>Going through the code above, we initialize our array of records which will be paginated by the user in the variable $myRecords.  I then create a Zend_Paginator object and pass in $myRecords into the factory method.  The Zend Framework then hooks everything else up for us behind the scenes and all we have to do is make sure we pass in the $currentPage the user is currently on and display the pagination links on our page.  </p>
<p><strong>The Problem<br />
</strong>So wheres the problem?  Well the problem lies in how users of the Zend_Paginator object are using it.  Many developers are using the Zend_Paginator object with database records errounously.  They hit the database, return ALL the records, store them into memory, and then allow Zend_Paginator to handle these potential HUGE record sets in the backend. Bleh  </p>
<p><em>Wrong way of doing it Example:</em></p>
<p><em><span style="font-style: normal;"> &lt;?php<br />
require_once &#8220;Zend/Loader.php&#8221;;<br />
Zend_Loader::loadClass(&#8221;Zend_Paginator&#8221;);</span></em></p>
<p><em><span style="font-style: normal;">//Initialize of DB object<br />
$db = new Zend_Db::factory() //Paraphrasing here.<br />
$statement = &#8220;SELECT * FROM Player&#8221;;<br />
$myRecords = $db-&gt;fetchAll($statement);</span></em></p>
<p><em><span style="font-style: normal;">//Create Paginator Object<br />
$Paginator = Zend_Paginator::factory($myRecords);</span></em></p>
<p><em><span style="font-style: normal;">//Set the current page were on.<br />
$Paginator-&gt;setCurrentPageNumber($currentPage);</span></em></p>
<p><em><span style="font-style: normal;">//Set the number of records to show per page<br />
$Paginator-&gt;setItemCountPerPage(3);</span></em></p>
<p><em><span style="font-style: normal;">//Save Paginator as View var.<br />
$this-&gt;view-&gt;paginator = $Paginator; <br />
?&gt;<br />
</span></em></p>
<p>Very inefficient.  </p>
<p><strong>The Solution</strong><br />
We don&#8217;t have to select ALL the records in the Db but allow Zend_Paginator to select and use small manageable pieces at a time for us.  How?  If we had a table with 1000000 records we dont have to select all records but construct a Zend_Db_Select object with the appropriate criteria, and then pass that into the factory instead of the array.  Lets take a look how this is done using the same Players table.</p>
<p><em>The right way of doing it</em></p>
<p>&lt;?php<br />
require_once &#8220;Zend/Loader.php&#8221;;<br />
Zend_Loader::loadClass(&#8221;Zend_Paginator&#8221;);</p>
<p>//Initialize of DB object<br />
Zend_Loader::loadClass(&#8221;Zend_Db&#8221;);<br />
$db = new Zend_Db::factory() //Paraphrasing here. </p>
<p>//Create Select Object<br />
Zend_Loader::loadClass(&#8221;Zend_Db_Select&#8221;);<br />
$selectStatement = $db-&gt;select()-&gt;from(&#8221;Players&#8221;);</p>
<p>//Create Paginator Object<br />
$Paginator = Zend_Paginator::factory($selectStatement);</p>
<p>//Set the current page were on.<br />
$Paginator-&gt;setCurrentPageNumber($currentPage);</p>
<p>//Set the number of records to show per page<br />
$Paginator-&gt;setItemCountPerPage(3);</p>
<p>//Save Paginator as View var.<br />
$this-&gt;view-&gt;paginator = $Paginator;<br />
?&gt;</p>
<p>Thats all there is too it.  Less memory consumption because we dont have fetch ALL our records at a time and allows the Zend Framework to do the heavy lifting for us. Hope this helps a few people looking for the answer to this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.armando.ws/2008/10/zend_paginator-and-your-result-set/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Poormans PHP Architecture</title>
		<link>http://www.armando.ws/2008/03/poormans-php-architecture/</link>
		<comments>http://www.armando.ws/2008/03/poormans-php-architecture/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 21:01:00 +0000</pubDate>
		<dc:creator>Armando Padilla</dc:creator>
				<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[apc]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php architecture]]></category>
		<category><![CDATA[smarty]]></category>

		<guid isPermaLink="false">http://www.armando.ws/?p=145</guid>
		<description><![CDATA[This is a proof of concept. Im using APC, memcached, and Smarty.
Smarty
I&#8217;ll be leveraging the Smarty front end caching engine for the fictitious application. The smarty engine caches all compiled templates and only updates if it identifies any updates to the page.
APC
Will be used to store compiled PHP code. Since PHP has to compile down [...]]]></description>
			<content:encoded><![CDATA[<p>This is a proof of concept. Im using APC, memcached, and Smarty.</p>
<p><strong>Smarty</strong><br />
I&#8217;ll be leveraging the Smarty front end caching engine for the fictitious application. The smarty engine caches all compiled templates and only updates if it identifies any updates to the page.</p>
<p><strong>APC</strong><br />
Will be used to store compiled PHP code. Since PHP has to compile down to opcode we can take away this overhead by storing opcode somewhere for the server to hit. Note: some test indicate that EAccelerator out performes APC. Might use that as a substitute instead of APC.</p>
<p><strong>Memcached</strong><br />
Will be used to reduce the number of hits on the DB. With the data initially pulled from the DB and stored in memory we dont have the overhead of opening a connection and quering the DB.<br />
I will test out this set up on one of my applications and see how well it does.</p>
<p>Armando Padilla</p>
]]></content:encoded>
			<wfw:commentRss>http://www.armando.ws/2008/03/poormans-php-architecture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
