<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Sun, 19 May 2013 11:36:01 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Web Species Blog: Lazy evaluation with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16410</guid>
      <link>http://www.phpdeveloper.org/news/16410</link>
      <description><![CDATA[<p>
<i>Juozas Kaziukenas</i> has a new post to his Web Species blog about <a href="http://blog.webspecies.co.uk/2011-05-31/lazy-evaluation-with-php.html">using "lazy evaluation" in PHP</a> - loading the resources you need for execution and evaluation only as you need them, not all up front.
</p>
<blockquote>
Recently I needed to process a huge array of data and because of PHP's somewhat inefficient variables and especially arrays that was resulting in "out of memory" errors. However, I couldn't use any other tools than PHP so was forced to come up with a solution implementation in it. Here is how I solved it using principles from functional languages.
</blockquote>
<p>
He gives an example using Haskell to generate a Fibonacci sequence using its built-in lazy evaluation abilities. Unfortunately, PHP doesn't have such a thing built in, so he tries the next best thing - <a href="http://php.net/manual/en/class.iterator.php">Iterators</a>. He caries the idea over to the database side too, recommending fetch() in a loop over fetchAll() and some effective joins.
</p>]]></description>
      <pubDate>Wed, 01 Jun 2011 08:41:01 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: Lazy and Eager Loading in PHP 5]]></title>
      <guid>http://www.phpdeveloper.org/news/13209</guid>
      <link>http://www.phpdeveloper.org/news/13209</link>
      <description><![CDATA[<p>
On DevShed today there's the start of a new series looking at design patterns in PHP applications. In <a href="http://www.devshed.com/c/a/PHP/Lazy-and-Eager-Loading-in-PHP-5">this first part</a> of the series, they look at lazy and eager loading.
</p>
<blockquote>
In the case of PHP 5, which is better suited for developing web-based programs, there are two complementary design patterns that can be of great help in  building faster and more reliable applications. Of course, as this article's title suggests, I'm talking about the lazy and eager loading patterns. Despite their rather funny names, they are pretty easy to implement in PHP 5-controlled environments.
</blockquote>
<p>
To illustrate, they've <a href="http://www.devshed.com/c/a/PHP/Lazy-and-Eager-Loading-in-PHP-5/1/">created a sample class</a> that uses a few class properties and a __toString method to return the values. 
</p>]]></description>
      <pubDate>Fri, 11 Sep 2009 12:49:30 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[BuildInternet.com: Why PHP Frameworks Matter]]></title>
      <guid>http://www.phpdeveloper.org/news/13033</guid>
      <link>http://www.phpdeveloper.org/news/13033</link>
      <description><![CDATA[<p>
From BuildInternet.com today there's <a href="http://buildinternet.com/2009/08/why-php-frameworks-matter/">a new article</a> from <i>Jason Gilmore</i> looking at PHP frameworks and why they matter to both the developers and the community at large.
</p>
<blockquote>
Having been a PHP programmer for more than a decade, I've come to realize that many of my fellow PHP programmers seem to have a misplaced notion of what being "lazy" is really all about. [...] Suddenly the Web developer was facing so much more than validating user input and connecting to a database [and] the need to be a lazy programmer was more important than ever.
</blockquote>
<p>
He covers a lot of the basics of frameworks with a focus on the Zend Framework (because of familiarity) - configuration, data validation tools, database connections, display helpers and the inclusion of third-party plugins.
</p>]]></description>
      <pubDate>Wed, 12 Aug 2009 11:09:50 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Giorgio Sironi's Blog: Doctrine 2 now has lazy loading]]></title>
      <guid>http://www.phpdeveloper.org/news/13013</guid>
      <link>http://www.phpdeveloper.org/news/13013</link>
      <description><![CDATA[<p>
As is mentioned in <A href="http://giorgiosironi.blogspot.com/2009/08/doctrine-2-now-has-lazy-loading.html">this new post</a> to <i>Giorgio Sironi</i>'s blog, the latest version of Doctrine now includes lazy loading functionality.
</p>
<blockquote>
Lazy loading is the capability of performing a expensive operation on demand, only when it reveals necessary from a client request. [...] In <a href="http://trac.doctrine-project.org/wiki/Doctrine2.0">Doctrine 2</a> I made some architectural choices implementing the proxy approach, which substitute a subclassing object to every association which is not eager-loaded.
</blockquote>
<p>
There's two main places you can see these differences - in the one/many to one associations dynamic proxies and collection interface.
</p>]]></description>
      <pubDate>Fri, 07 Aug 2009 11:07:37 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Giorgio Sironi's Blog: Lazy loading of objects from database]]></title>
      <guid>http://www.phpdeveloper.org/news/12914</guid>
      <link>http://www.phpdeveloper.org/news/12914</link>
      <description><![CDATA[<p>
In <a href="http://giorgiosironi.blogspot.com/2009/07/lazy-loading-of-objects-from-database.html">recent post</a> to his blog <i>Giorgio Sironi</i> takes a look at a handy feature that PHP makes it relatively simple to work with objects in your applications - lazy loading.
</p>
<blockquote>
What is lazy loading? A practice in object/relational mapping which simulate the presence of the whole object graph in memory. There is some techniques for produce this illusion that I explain here. [...] The main problem is that we cannot load all the object graph, because it will not fit in the memory of the server and it will take much time to build, depending on the size of the database. Nor we can load an arbitrary subset of it.
</blockquote>
<p>
His solution is to use the <a href="http://en.wikipedia.org/wiki/Proxy_pattern">proxy design pattern</a> to create an interface allowing only the first level of information to be loaded by default. After that, each of the sub-levels have what they need to load themselves and the data that might be needed inside.
</p>]]></description>
      <pubDate>Tue, 21 Jul 2009 12:48:54 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Terry Chay's Blog: Autoloading and Lazy Loading]]></title>
      <guid>http://www.phpdeveloper.org/news/12411</guid>
      <link>http://www.phpdeveloper.org/news/12411</link>
      <description><![CDATA[<p>
In <a href="http://terrychay.com/blog/article/autoloading-and-lazy-loading.shtml">this recent post</a> to his blog <i>Terry Chay</i> points out one way he (and Tagged) used to help prevent things like "unknown class" errors in their code - lazy loading.
</p>
<blockquote>
It's not that Andrei is wrong in his admonition. Far from it! For reasons that I don't quite care to know, there are caching and lookup optimizations that APC cannot do when it has to switch context to run __autoload.
</blockquote>
<p>
They did see a performance boost from the code rewrite it took to make this happen but, since not everyone can take the time to optimize their code like this, he also suggests <a href="http://tekrat.com/2009/03/10/apc-lazy-loading-initial-support/">another way</a> (as written up by <i>Brian Shire</i>). It uses two settings for <a href="http://pecl.php.net/package/APC//">APC</a> in your php.ini file and the latest versions of PHP 5.3 & APC along with <a href="http://tekrat.com/downloads/bits/apc_lazy_php53.patch">this patch</a> to make them work.
</p>]]></description>
      <pubDate>Mon, 27 Apr 2009 11:14:26 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Padraic Brady's Blog: Unit Testing: Multiple Assertions And Lazy/Shallow Testing Are Evil]]></title>
      <guid>http://www.phpdeveloper.org/news/11945</guid>
      <link>http://www.phpdeveloper.org/news/11945</link>
      <description><![CDATA[<p>
In <a href="http://blog.astrumfutura.com/archives/387-Unit-Testing-Multiple-Assertions-And-LazyShallow-Testing-Are-Evil.html">a new post</a> today <i>Padraic Brady</i> takes a look at unit testing and two of the bad practices that can develop over time when writing your tests - overloading tests with assertions and lazy/shallow tests.
</p>
<blockquote>
In short, every test you write requires that you setup the test environment, create a scenario for possible failure, add an assertion, and then ensure the source code makes that assertion pass. This requires code - sometimes a lot of code. So adding multiple assertions to each test minimizes the work needed to write tests, since using multiple assertions takes advantage of existing code to avoid writing new stuff to clutter your test classes. It can also help to tackle multiple but related results in the same test.
</blockquote>
<p>
He gives brief examples of both instances and some of the problems associated with them. Multiple assertions, while nice for fine tuning the results of the testing, can also confuse since, if one assertion fails, the whole test fails too. The other end of the spectrum is a problem too - writing tests that don't do enough to really check the information passed in. These shallow tests can lead to issues down the line if unanticipated data might come along. 
</p>
<p>
Really, its all about finding that "sweet spot" in developing tests - not too much, not too little - and keeping it simple while not missing out on assertions that need to be made.
</p>]]></description>
      <pubDate>Fri, 13 Feb 2009 09:31:33 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Stefan Esser's Blog: Suhosin Updates - Improved Randomness & LAZY Symbol Loading]]></title>
      <guid>http://www.phpdeveloper.org/news/10892</guid>
      <link>http://www.phpdeveloper.org/news/10892</link>
      <description><![CDATA[<p>
<i>Stefan Esser</i> has released a new update (really two, but one is the latest) to his <a href="http://www.suhosin.org/">Suhosin patch</a> for PHP - version 0.9.27.
</p>
<p>
The previous update (0.9.26) updated the utility with an improved randomness fixing a few issues with an ini setting and the uploadprogress extension as well as adding in a few new settings and updates to the randomizing functions that come included in PHP.
</p>
<p>
The 0.9.27 update (the most current) updates the patch with a lazy loading change that allows it to work correctly on systems that have it disabled by default (causing the previous patch to not work).
</p>
<p>
You can grab this latest release, 0.9.27, from <a href="http://www.suhosin.org/">the suhosin website</a>.
</p>]]></description>
      <pubDate>Mon, 25 Aug 2008 12:06:01 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Cormac's Blog: Lazy loading of object variables in php using __get()]]></title>
      <guid>http://www.phpdeveloper.org/news/10795</guid>
      <link>http://www.phpdeveloper.org/news/10795</link>
      <description><![CDATA[<p>
Recently, <i>Cormac</i> posted <a href="http://cormacscode.wordpress.com/2008/08/01/lazy-loading-in-php-using-__get/">this look at</a> a method for lazy loading on variables in an object with the magic __get method.
</p>
<blockquote>
I used the magic method __get() to load the images into the [Product] object when they were needed. __get() is called whenever something tries to access a variable that is not set or publically accessible, so basically I used that to load the images whenever some other piece of code tried to access Product::images.
</blockquote>
<p>
He includes a quick bit of code that fires off an internal private method for the class that loads up the images. In his example, if they're already loaded, it never gets called.
</p>]]></description>
      <pubDate>Fri, 08 Aug 2008 14:22:51 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Alex Netkachov's Blog: 6 PHP coding tips to write less code]]></title>
      <guid>http://www.phpdeveloper.org/news/8967</guid>
      <link>http://www.phpdeveloper.org/news/8967</link>
      <description><![CDATA[<p>
<i>Alex Netkachov</i> has <a href="http://www.alexatnet.com/node/100">shared six tips</a> in a new post on his blog today for how you can write less PHP code and get more done with it. It's based around <a href="http://www.phpdeveloper.org/news/8961">another post</a> from <i>Arnold Daniels</i> talking about a temporary variable method in PHP.
</p>
<blockquote>
This tip is useful to "lazy" developers who do not even think about variable names. They may prefer magic names like ${0} and 0 is good enough variable name, why not...
</blockquote>
<p>
His <a href="http://www.alexatnet.com/node/100">list</a> consists of:
</p>
<ul>
<li>Use || (or) and && (and) operations instead of if.
<li>Use ternary operator.
<li>Use for instead of while.
<li>In some cases PHP requires you to create a variable. [...] To handle all these situation you can create a set of small functions which shortcuts frequently used operations.
<li>Explore the language you use.
<li>When it is better to write more and then read the code easily, do not be lazy.
</ul>
<p>
Check out <a href="http://www.phpcult.com/blog/02/less-code-vs-good-code/">Vidyut Luther's response</a> to <i>Alex</i>'s comments as well as one from <a href="http://www.phpguru.org/#154">Richard Heyes</a>.
</p>]]></description>
      <pubDate>Mon, 05 Nov 2007 07:58:00 -0600</pubDate>
    </item>
  </channel>
</rss>
