<?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, 12 Feb 2012 21:56:17 -0600</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Refulz.com: The __toString() Method - Objects as Strings]]></title>
      <guid>http://www.phpdeveloper.org/news/17523</guid>
      <link>http://www.phpdeveloper.org/news/17523</link>
      <description><![CDATA[<p>
On the Refulz.com blog there's a <a href="http://php.refulz.com/magic-methods-in-php-tostring-method/">recent post</a> introducing the __toString() magic method in PHP. This handy method allows you to define how to return an object when it's referenced as a string.
</p>
<blockquote>
We started the study of PHP magic methods by learning about <a href="http://php.refulz.com/magic-methods-in-php-__get-method/">__get() magic method</a>. [...] PHP is loosely typed language and same variable can be used or referred as string, number or object. The __toString() method is called when the code attempts to treat an object like a string. This function does not accept any arguments and should return a string.
</blockquote>
<p>
Some quick code is included showing how it works - returning a combined string made from two private class properties when the object ($obj) is echoed out. They also show multiple ways of using the method in both pre- and post-PHP 5.2.
</p>]]></description>
      <pubDate>Thu, 09 Feb 2012 09:27:19 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Developer Drive: Building a PHP Ad Tracker: Data Object Design and Coding]]></title>
      <guid>http://www.phpdeveloper.org/news/17518</guid>
      <link>http://www.phpdeveloper.org/news/17518</link>
      <description><![CDATA[<p>
Continuing on from <a href="http://phpdeveloper.org/news/17400">the first part</a> of their tutorial series about creating a simple ad tracker for your web application, Developer Drive is back with <a href="http://www.developerdrive.com/2012/02/php-ad-tracker-part-ii-data-object-design/">part two</a>, a more in-depth look at the actual object design and code.
</p>
<blockquote>
In our last PHP Ad Tracker lesson, we constructed the database tables for our ad banner application. Now we are ready to construct the data object that will hold the variables and functions that will display, add, edit and delete the data in those tables.
</blockquote>
<p>
They cover each of the variables they'll be using with a summary of what they're used for as well as the various functions to be defined and what they'll return. Following this, they get into the actual development - creating an "ads" class and defining the methods to get the current ad count, get the number of clients and pull the actual client/ad data.
</p>]]></description>
      <pubDate>Wed, 08 Feb 2012 12:57:54 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Jakub Zalas' Blog: Mocking Symfony Container services in Behat scenarios with Mockery]]></title>
      <guid>http://www.phpdeveloper.org/news/17428</guid>
      <link>http://www.phpdeveloper.org/news/17428</link>
      <description><![CDATA[<p>
<i>Jakub Zalas</i> has <a href="http://www.zalas.eu/mocking-symfony-container-services-in-behat-scenarios-with-mockery">a recent post</a> to his blog with a hint about how to test Symfony container services by mocking them (when testing with <A href="http://behat.org/">Behat</a>) with the help of <a href="https://github.com/padraic/mockery">Mockery</a> (and the <a href="https://github.com/PolishSymfonyCommunity/PSSMockeryBundle">PSSMockeryBundle</a>).
</p>
<blockquote>
Mocking objects in unit tests is pretty straightforward as every object used in a test case is usually created in a scope of one test class. In functional tests it's a bit harder since we either don't have full control over objects being created or it's simply too laborious to mock half the framework. [...] We're getting the service from a container [in the example] and calling a method which should send a lead. The problem is we don't want to actually call an API while executing Behat scenarios.
</blockquote>
<p>
Rather than hitting up the API for each test, he opts to create mock objects and results with the tools <a href="https://github.com/padraic/mockery">Mockery</a> has to offer. He gives code for a "is API available" method that either returns a valid container or a mocked object, depending on how it was called.
</p>]]></description>
      <pubDate>Fri, 20 Jan 2012 13:54:52 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Davey Shafik's Blog: The Closure Puzzle]]></title>
      <guid>http://www.phpdeveloper.org/news/17397</guid>
      <link>http://www.phpdeveloper.org/news/17397</link>
      <description><![CDATA[<p>
<i>Davey Shafik</i> has <a href="http://daveyshafik.com/archives/32789-the-closure-puzzle.html">posted about an interesting find with closures</a> in PHP revolving around an update to add "$this" access inside the closure.
</p>
<blockquote>
However, it didn't stop there; there was also the addition of Closure::bind() and Closure->bindTo(). These methods are identical except one is a static method into which the closure is passed, the second an instance method on the closure itself. These methods both take two arguments (on top of the closure for the static version): $newthis and $newscope. What this means is that unlike the regular object model the concept of $this and lexical scope (what is in scope for the function with regards to private/protected methods inside objects) are completely separated.
</blockquote>
<p>
He also mentions that you can change the "$this" to a different object (complex) or swapping out the object the closure is bound to while keeping "$this" the same (simpler). He mentions that it could be useful for unit testing but can have its drawbacks. He's <a href="https://gist.github.com/1607647">included code</a> to illustrate 
 the breakage it can cause in the PHP OOP model (with an explanation).
</p>]]></description>
      <pubDate>Mon, 16 Jan 2012 09:52:38 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Chris Hartjes' Blog: Better HTTP Request/Response in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17256</guid>
      <link>http://www.phpdeveloper.org/news/17256</link>
      <description><![CDATA[<p>
In a recent post to his blog <i>Chris Hartjes</i> looks at the idea of <a href="http://www.littlehart.net/atthekeyboard/2012/12/12/better-http-request-response-in-php/">better HTTP Request/Response functionality</a> in PHP, more than just the <a href="http://us3.php.net/manual/en/language.variables.superglobals.php">superglobal</a> handling and <a href="http://www.php.net/http">PECL HTTP extension</a> it has now.
</p>
<blockquote>
I think the fact that we have $_POST and $_GET lulls some of us into the false sense that we should have $_PUT and $_DELETE objects, since that would map to the commonly-desired set of HTTP verbs that REST likes to use. But what should be inside those things, or should we be moving towards a more Pythonesque solution where a Request object, as part of core or via a only-really-for-the-brave- PECL extension?
</blockquote>
<p>
He mentions opinions from other PHP community members (<a href="http://twitter.com/lxt">Laura Thompson</a> and <a href="http://twitter.com./auroraeosrose">Elizabeth Smith</a>) and a bit about what he (and I'm sure other developers) are looking for in a more full-featured request/response handling feature.
</p>]]></description>
      <pubDate>Wed, 14 Dec 2011 09:51:03 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[VG Tech Blog: Unit Testing with Streams in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17229</guid>
      <link>http://www.phpdeveloper.org/news/17229</link>
      <description><![CDATA[<p>
On the VG Tech blog today there's a new post from <i>Andr&eacute; Roaldseth</i> about using <a href="http://phpunit.de">PHPUnit</a> to <a href="http://tech.vg.no/2011/06/27/unit-testing-with-streams-in-php/">test PHP streams</a>, basing the assertions on the data rather than the functionality itself.
</p>
<blockquote>
Using the memory/temporary stream provided by php:// stream wrapper you  can create a stream with read and write access directly to RAM or to a temporary file [using "php://memory"]. This gives you the possibilty to write unit tests that does not rely on a specific file, resource or stream, but rather on data provided by the test itself.
</blockquote>
<p>
There's no specific code examples here, but you can refer to the <a href="http://us3.php.net/manual/en/wrappers.php.php">stream wrappers</a> section of the PHP manual for more details on this and other handy built-in streams. Once created, it can then be used just as <a href="http://no.php.net/manual/en/book.stream.php">any other stream resource</a> can. This could be useful to provide mocks in your testing, replacing any other stream-able resource with a "memory" or "temp" placeholder.
</p>]]></description>
      <pubDate>Thu, 08 Dec 2011 09:13:28 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[CloudSpring.com: Using the Rackspace PHP SDK]]></title>
      <guid>http://www.phpdeveloper.org/news/17137</guid>
      <link>http://www.phpdeveloper.org/news/17137</link>
      <description><![CDATA[<p>
On the CloudSpring site today there's the continuation of a <a href="http://http//cloudspring.com/rackspace-cloud-files/">previous article</a> about RackSpace's CloudFiles API. In <a href="http://cloudspring.com/using-the-rackspace-php-sdk/">this new post</a> they show how to use their <a href="https://github.com/rackspace/php-cloudfiles">PHP SDK</a> to connect to and use the CloudFiles service.
</p>
<blockquote>
Rackspace provides a Software Development Kit (SDK) for multiple programming languages. They store their PHP SDK on <a href="https://github.com/rackspace/php-cloudfiles">GitHub</a>. The PHP SDK requires PHP 5 with the following modules: cURL, FileInfo and mbstring. In this tutorial we are going to review use of the PHP SDK with CloudFiles. Not all parts of the API will be covered but you will get a great start.
</blockquote>
<p>
Code is included showing how to make the connection, work with containers, pushing content out to a CDN, object handling and a few other handy tips (and API info) to help you along your way.
</p>]]></description>
      <pubDate>Wed, 16 Nov 2011 12:10:38 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Stoimen Popov's Blog: PHP: Don't Call the Destructor Explicitly]]></title>
      <guid>http://www.phpdeveloper.org/news/17136</guid>
      <link>http://www.phpdeveloper.org/news/17136</link>
      <description><![CDATA[<p>
In <a href="http://www.stoimen.com/blog/2011/11/14/php-dont-call-the-destructor-explicitly/">this new post</a> to his blog <i>Stoimen Popov</i> talks about calling the "destructor" method of an object and why doing it directly could lead to some issues - like not actually destroying the object before the script ends.
</p>
<blockquote>
At the end of the script the interpreter frees the memory. Actually every object has a built-in destructor, just like it has built-in constructor. So even we don't define it explicitly, the object has its destructor. Usually this destructor is executed at the end of the script, or whenever the object isn't needed anymore. This can happen, for instance, at the end of a function body. Now if we call the destructor explicitly, which as I said I've seen many times, here's what happen. As you can see calling the destructor explicitly doesn't destroy the object. So the question is...how to destroy an object before the script stops?
</blockquote>
<p>
He points out that one way to "destroy" an object is to null it out and remove the structure from memory. This is tricky, though, because a clone of the object will still exist in memory, just not the original.
</p>]]></description>
      <pubDate>Wed, 16 Nov 2011 11:56:43 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Wojciech Sznapka's Blog: Why Mockery is better than PHPUnit Mock Builder (with Symfony2)]]></title>
      <guid>http://www.phpdeveloper.org/news/17074</guid>
      <link>http://www.phpdeveloper.org/news/17074</link>
      <description><![CDATA[<p>
<i>Wojciech Sznapka</i> has a new post today sharing his opinions as to why <a href="http://blog.sznapka.pl/why-mockery-is-better-than-phpunit-mock-builder-and-how-to-integrate-it-with-symfony2">Mockery is better than PHPUnit Mock Builder</a> in testing Symfony2-based applications.
</p>
<blockquote>
Recently I did a lot of Test Driven Development on my Symfony2 bundle. I used PHPUnit's built-in <a href="http://www.phpunit.de/manual/3.5/en/test-doubles.html">mocks and stubs</a> for many projects, so I took it again. But while I was working on mocking Symfony2 core objects I found those mocks very uncomfortable in use. I tried <a href="http://blog.astrumfutura.com/2009/03/the-mockery-an-independent-mock-object-and-stub-framework-for-php5/">Mockery</a> and it saved my day. Let's see how to get it working with Symfony2 and how it kicks ass!
</blockquote>
<p>
He shows how to get things set up - adding Mockery to the dependencies file (deps), getting the latest version from their git repository and an example mock method that shows the difference in mocking the Doctrine2 entity manager - PHPUnit vs Mockery.
</p>]]></description>
      <pubDate>Wed, 02 Nov 2011 13:02:06 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[DZone.com: Closure Object Binding in PHP 5.4]]></title>
      <guid>http://www.phpdeveloper.org/news/17054</guid>
      <link>http://www.phpdeveloper.org/news/17054</link>
      <description><![CDATA[<p>
In a new post to DZone.com <i>Mitchell Pronschinske</i> looks at <a href="http://css.dzone.com/articles/closure-object-binding-php-54">closure object binding</a> in PHP 5.4 applications (yes, we know PHP 5.4 isn't released yet). He explains what this is an shows some sample use cases for you to consider in your development.
</p>
<blockquote>
For the people who read PHP's NEWS file, it's no surprise - but for all who don't here's is probably one of the biggest features of PHP 5.4: Closure Object Support is back. For me it's something I missed the most, when Closures were introduced in PHP 5.3. So I'm very happy, that's finally here (or back). I'm going to tell you about the rocky road which closure object binding support had and show you some simple use cases for it.
</blockquote>
<p>
The functionality, based on <a href="https://wiki.php.net/rfc/closures/object-extension">this RFC</a>, lets you more correctly bind closures to objects instead of having to pass the objects into the closure at create time. He includes an example from a <a href="http://silex.sensiolabs.org/">Silex</a> framework application and <a href="https://gist.github.com/1121233">an example</a> that refactors a helper method as a part of rendering a simple template.
</p>]]></description>
      <pubDate>Fri, 28 Oct 2011 08:43:26 -0500</pubDate>
    </item>
  </channel>
</rss>

