<?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>Mon, 21 May 2012 07:33:06 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Gonzalo Ayuso's Blog: Building a small microframework with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16756</guid>
      <link>http://www.phpdeveloper.org/news/16756</link>
      <description><![CDATA[<p>
In investigating microframeworks and some of the offerings out there <i>Gonzalo Ayuso</i> has done a little exploring of his own. He's <a href="http://gonzalo123.wordpress.com/2011/08/22/building-a-small-microframework-with-php/">worked up a basic microframework</a> and shared it in a new post as a sort of academic exercise.
</p>
<blockquote>
Nowadays microframewors are very popular. Since Blake Mizerany created <a href="http://www.sinatrarb.com/">Sinatra</a> (Ruby), we have a lot of Sinatra clones in PHP world. Probably the most famous (and a really good one) is <a href="http://silex-project.org/">Silex</a>. But we also have several ones, such as <a href="http://www.limonade-php.net/">Limonade</a>, <a href="http://gluephp.com/">GluePHP</a> and <a href="http://www.slimframework.com/">Slim</a>. Those frameworks are similar. 
</blockquote>
<p>
He looks at how several of these frameworks handle routing and setup, mostly using the closures/anonymous function callbacks available in PHP 5.3. His <a href="https://github.com/gonzalo123/microFramework">simple example framework</a> does some basic URI handling to find the requested module, class and function (action) to call. You can even define the output format from options like json, txt, css, js and jsonp. A sample "controller" is included with a "Hello world" and there's a mention of some other options he's exploring including <a href="http://twig-project.org">Twig</a> and <a href="https://github.com/kriswallsmith/assetic">Assetic</a> integration.
</p>]]></description>
      <pubDate>Tue, 23 Aug 2011 09:48:27 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Ryan Gantt's Blog: Anonymous recursion in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16705</guid>
      <link>http://www.phpdeveloper.org/news/16705</link>
      <description><![CDATA[<p>
In a recent post to his blog <i>Ryan Gantt</i> looks at an interesting way to get around a limitation in PHP dealing with <a href="http://zuttonet.com/articles/anonymous-recursion-php/">anonymous recursion and closures</a> that throws a Fatal error when called.
</p>
<blockquote>
Turns out that variables called as functions must be an instance of Closure, an instance of a class which implements __invoke(), or a string representing a named function in the global namespace. In the anonymous function body above, $fibonacci is none of these. It is an undeclared, free variable in the closure created by the anonymous function. At the time when it's called, it hasn't been bound-hence the Notice that you would have gotten if error reporting were set at a high enough threshold - and therefore can't be called as anything, let alone as a function.
</blockquote>
<p>
He tried using the "use" functionality PHP closures have to bring a variable/object/etc into the scope of the running function, but it still threw an error. As it turns out, the combination of "use"-ing the object and calling it by reference handles things correctly. He takes this method and applies it in two examples - one call in an <a href="http://php.net/array_map">array_map</a> function and another in an <a href="http://php.net/array_reduce">array_reduce</a>.
</p>]]></description>
      <pubDate>Thu, 11 Aug 2011 10:55:35 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Fabian Schmengler's Blog: Anonymous function calls in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/15962</guid>
      <link>http://www.phpdeveloper.org/news/15962</link>
      <description><![CDATA[<p>
<i>Fabian Schmengler</i> has a new post today looking a <a href="http://www.schmengler-se.de/anonymous-function-calls-in-php">using anonymous function calls</a> in PHP. He relates to to another popular language that allows for dynamic anonymous functions - Javascript.
</p>
<blockquote>
Anonymous function calls are a well-known pattern in JavaScript but there are also use cases in PHP where they make sense. Of course PHP 5.3 with its Lambda Functions is required!
</blockquote>
<p>
He includes several little code snippets showing how the anonymous functions work including the "use" keyword functionality that lets you import variables from outside the function. There's a sneaky pass-by-reference in there, so don't get tripped up.
</p>]]></description>
      <pubDate>Fri, 25 Feb 2011 09:52:27 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Lorna Mitchell's Blog: Callbacks in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/15902</guid>
      <link>http://www.phpdeveloper.org/news/15902</link>
      <description><![CDATA[<p>
<i>Lorna Mitchell</i> has a new post to her blog today looking at a very handy piece of PHP functionality sprinkled around in different functions - <a href="http://www.lornajane.net/posts/2011/Callbacks-in-PHP">using callbacks</a> to handle complicated processing.
</p>
<blockquote>
Recently I was working on something and I wanted to call an object method as a callback, but got confused when I realised the method had been caused statically. This was caused by my inability to RTFM and I wondered how I'd come so far without actually coming across the many and varied things you can pass into any place a callback is needed.
</blockquote>
<p>
Besides the normal callback functions you can put in something like <a href="http://php.net/call_user_func">call_user_func</a>, she also mentions something a bit more powerful - passing in an array that contains a pointer to an object and a method inside it. <a href="http://uk2.php.net/manual/en/language.pseudo-types.php#language.types.callback">This ability</a> allows you to keep your OOP encapsulation intact without having to make global functions. In PHP 5.3, there's even some of the PHP functions that use call backs that will allow you to use <a href="http://www.php.net/manual/en/functions.anonymous.php">closures/anonymous functions</a> without even having to make a separate function.
</p>]]></description>
      <pubDate>Mon, 14 Feb 2011 13:41:28 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Devis Lucato's Blog: Anonymous objects in PHP - Composition, Mocks, Refactoring]]></title>
      <guid>http://www.phpdeveloper.org/news/15480</guid>
      <link>http://www.phpdeveloper.org/news/15480</link>
      <description><![CDATA[<p>
In <a href="http://lucato.it/php-anonymous-objects">a new post</a> to his blog <i>Devis Lucato</i> points out something he noticed when working with objects and anonymous functions/closures - they're not all as they seem.
</p>
<blockquote>
Both solutions allow to instantiate an anonymous object with properties. They are used as value objects and have no other purpose than storing values, so no logic can be included and they don't come with methods.  They can be used as function parameters instead of arrays, for instance. PHP 5.3.0 introduced anonymous functions and closures, so it is now possible to attach functions to these VOs (*). [...] The first thing to notice is that these properties are not methods but callable functions:
</blockquote>
<p>
In his example, an anonymous function dynamically appended to an object doesn't have access to a property set on the object just one line before. There's a way around it with <a href="http://php.net/call_user_func">call_user_func</a>, but it's not practical. His proposed solution is to create a type of Anonymous class that uses the __call method to catch the methods and translate them into calls to <a href="http://php.net/call_user_func_array">call_user_func_array</a> automatically. 
</p>]]></description>
      <pubDate>Tue, 23 Nov 2010 13:17:53 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Sameer Borate's Blog: Anonymous functions in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/14613</guid>
      <link>http://www.phpdeveloper.org/news/14613</link>
      <description><![CDATA[<p>
On his blog today <i>Sameer Borate</i> has <a href="http://www.codediesel.com/php/anonymous-functions-in-php">a new post</a> talking about anonymous functions (closures, lambdas) in PHP and includes plenty of examples of how to use them.
</p>
<blockquote>
Anonymous functions are common in various modern languages, Ruby and Javascript being the popular one. But until version 5.3 PHP lacked true anonymous functions. Although newbie programmers are hard-pressed to find a suitable application for anonymous functions, they are indispensable if you do a lot of OOP, and can provide some elegant solutions to some particular problems.
</blockquote>
<p>
He starts with a look at variable functions both in procedural code an object-oriented then moves to the anonymous/lambda function examples (with some nexting involved) and a few uses for closures.
</p>]]></description>
      <pubDate>Mon, 07 Jun 2010 12:42:33 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Jani Hartikainen's Blog: What is a null object, and when are they useful?]]></title>
      <guid>http://www.phpdeveloper.org/news/13219</guid>
      <link>http://www.phpdeveloper.org/news/13219</link>
      <description><![CDATA[<p>
In <a href="http://codeutopia.net/blog/2009/09/12/what-is-a-null-object-and-when-are-they-useful/">this latest post</a> to his blog <i>Jani Hartikainen</i> looks at creating "null objects" for your applications - a simple tool that lets you replace multiple evaluation checks with a simple object.
</p>
<blockquote>
How many times have you written code, which checks if a value is null, and then displays something special because of that? Have you written the very same check in more than one place in your code? A null object is an elegant solution to this. 
</blockquote>
<p>
His example shows how to replace a standard User class to grab the user's name with an anonymous user that extends it to return the string "Anonymous User" instead. By creating an intermediate class like this, you can simple call a "getName" and know that there will be some sort of value as the result.
</p>]]></description>
      <pubDate>Mon, 14 Sep 2009 12:46:10 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Recess Blog: Functional PHP 5.3 Part I - What are Anonymous Functions and Closures?]]></title>
      <guid>http://www.phpdeveloper.org/news/13070</guid>
      <link>http://www.phpdeveloper.org/news/13070</link>
      <description><![CDATA[<p>
Those still trying to get a handle on anonymous functions, lambdas and closures in the recently released 5.3 version of PHP might want to take a look at <a href="http://www.recessframework.org/page/functional-php-anonymous-functions-lambdas-closures">this new tutorial</a> from the Recess blog. It's the first part of their "Functional PHP 5.3" series.
</p>
<blockquote>
One of the most exciting features of PHP 5.3 is the first-class support for <a href="http://us.php.net/manual/en/functions.anonymous.php">anonymous functions</a>. You may have heard them referred to as <a href="http://us.php.net/manual/en/functions.anonymous.php">closures</a> or lambdas as well. There's a lot of meaning behind these terms so let's straighten it all out.
</blockquote>
<p>
They explain the differences between closures and lambda functions (hint: not much) and give code examples for both them and closures.
</p>]]></description>
      <pubDate>Wed, 19 Aug 2009 11:56:50 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Juozas Kaziukenas' Blog: Lambda functions are coming to PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/12235</guid>
      <link>http://www.phpdeveloper.org/news/12235</link>
      <description><![CDATA[<p>
In <a href="http://dev.juokaz.com/php/lambda-function-coming-to-php">this recent post</a> to his blog <i>Juozas Kaziukenas</i> looks at one of the features in the next major upcoming release of PHP (5.3) - lambda functions (anonymous functions).
</p>
<blockquote>
Only some days ago PHP.net introduced <a href="http://www.php.net/archive/2009.php#id2009-03-24-1>5.3.0RC1</a> version, but future features have been known for quite a while. Namespaces and <a href="http://en.wikipedia.org/wiki/Lambda_function">lambda functions</a> (+ closures) are most anticipated, because they'll increase flexibility and good-looks of code a lot. Today I'm going to try to prove why lambda functions are so useful.
</blockquote>
<p>
He looks at what lambda functions are and one of their more apparent uses - sorting. He gives an example working with information about authors and their books, sorting them by publisher and title.
</p>]]></description>
      <pubDate>Mon, 30 Mar 2009 12:04:36 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Timothy Boronczyk's Blog: Anonymous Functions and Closures]]></title>
      <guid>http://www.phpdeveloper.org/news/12104</guid>
      <link>http://www.phpdeveloper.org/news/12104</link>
      <description><![CDATA[<p>
<i>Timothy Boronczyk</i> has <A href="http://zaemis.blogspot.com/2009/03/anonymous-functions-and-closures.html">written up a new blog post</a> about two of the features he's most excited about in the upcoming PHP 5.3 release - anonymous functions and closures.
</p>
<blockquote>
As of version 5.3, PHP will offer better support for anonymous functions and a new syntax which supports closures. [...] Anonymous functions are functions that are defined without being bound to a proper name. Typically, anonymous functions are used only a limited number of times and for a specific purpose; you could think of them as "throw-away" functions if you'd like.
</blockquote>
<p>
He <A href="http://zaemis.blogspot.com/2009/03/anonymous-functions-and-closures.html">includes some code examples</a> showing how the anonymous functions can replace the current <A href="http://php.net/create_function">create_function</a> method and how closures can effectively import variable values into the current scope just like they were passed in.
</p>]]></description>
      <pubDate>Tue, 10 Mar 2009 12:57:08 -0500</pubDate>
    </item>
  </channel>
</rss>

