<?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>Fri, 24 May 2013 08:10:09 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[DZone.com: How to correctly work with PHP serialization]]></title>
      <guid>http://www.phpdeveloper.org/news/18416</guid>
      <link>http://www.phpdeveloper.org/news/18416</link>
      <description><![CDATA[<p>
In <a href="http://css.dzone.com/articles/how-correctly-work-php">this new post</a> to DZone.com today <i>Giorgio Sironi</i> takes a look at the serializing functionality in PHP and how it works with both regular variables and objects.
</p>
<blockquote>
PHP is able to automatically serialize most of its variables to strings - letting you save them into storage like $_SESSION. However, there are some tweaks you have to know to avoid exploding .php scripts and performance problems.
</blockquote>
<p>
He gives some code snippets showing the serialization of variables and objects and points out a few things that can't be effectively serialized (like resources and closures). The mentions the "__sleep" and "__wakeup" magic methods for automatic class serialization and mentions the <a href="http://php.net/Serializable"> Serializable</a> interface that comes built in to PHP.
</p>]]></description>
      <pubDate>Wed, 29 Aug 2012 08:19:37 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Justin Carmony's Blog: PHP, Sessions, __sleep, and Exceptions]]></title>
      <guid>http://www.phpdeveloper.org/news/17738</guid>
      <link>http://www.phpdeveloper.org/news/17738</link>
      <description><![CDATA[<p>
<i>Justin Carmony</i> has a recent post to his blog about a problem he came across where his exception was being thrown with a line number of zero - cause for <a href="http://www.justincarmony.com/blog/2012/03/23/php-sessions-__sleep-and-exceptions/">some investigation</a>.
</p>
<blockquote>
Today I ran into a problem where my PHP Application would throw this fatal error: "Fatal error: Exception thrown without a stack frame in Unknown on line 0". Which is so much fun, because it doesn't have a line number, so I had no direction as to what exactly was causing the problem. 
</blockquote>
<p>
He found <a href="http://www.compdigitec.com/labs/2009/08/02/solving-fatal-error-exception-thrown-without-a-stack-frame-in-unknown-on-line-0/">a blog post</a> that helped him track down the issue that, as it turns out, with serializing objects into the session and an error in the __sleep method.
</p>]]></description>
      <pubDate>Tue, 27 Mar 2012 12:25:02 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Dave Gardner's Blog: Caching dependency-injected objects]]></title>
      <guid>http://www.phpdeveloper.org/news/14247</guid>
      <link>http://www.phpdeveloper.org/news/14247</link>
      <description><![CDATA[<p>
<i>Dave Gardner</i> has posted about a method he uses to <a href="http://www.davegardner.me.uk/blog/2010/03/22/caching-dependency-injected-objects-with-php/">cache objects</a> that have dependency injection needs in something like a <a href="http://php.net/manual/en/book.memcache.php">memcached</a> server.
</p>
<blockquote>
The objects themselves have a number of injected dependencies. It includes using the PHP magic methods __sleep and __wakeup to manage <a href="http://uk.php.net/manual/en/function.serialize.php">serialisation</a>. It also discusses mechanisms for re-injecting dependencies on wakeup via a method that maintains <a href="http://en.wikipedia.org/wiki/Inversion_of_control">Inversion of Control</a> (IoC).
</blockquote>
<p>
He uses a user object based example that has an injection needed to load in the user's usage history. He includes the code to define the classes, create the objects via a dependency injection container and performing the sleep/wakeup actions with the dependencies coming out intact on the other side.
</p>]]></description>
      <pubDate>Thu, 25 Mar 2010 11:49:57 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: The Sleep and Wakeup Magic Functions in PHP 5]]></title>
      <guid>http://www.phpdeveloper.org/news/12699</guid>
      <link>http://www.phpdeveloper.org/news/12699</link>
      <description><![CDATA[<p>
DevShed has <a href="http://www.devshed.com/c/a/PHP/The-Sleep-and-Wakeup-Magic-Functions-in-PHP-5">posted the next part</a> of their series looking at the "magic functions" that PHP5+ has to offer you in your development. They've already looked at ones like <a href="http://www.phpdeveloper.org/news/12645">__call</a>, <a href="http://www.phpdeveloper.org/news/12688">__clone</a> and <a href="http://www.phpdeveloper.org/news/12610">__isset/__unset</a> and now, with this new tutorial they've added __sleep and __wake.
</p>
<blockquote>
Magic functions are an important part of the numerous improvements and additions that were introduced originally in PHP 5. They can be extremely handy when it comes to simplifying the execution of complex tasks. [...] In this fourth chapter I'm going to examine closely the "__sleep()" and "__wakeup()" functions, which are called automatically when an object is serialized and unserialized respectively.
</blockquote>
<p>
In <a href="http://www.devshed.com/c/a/PHP/The-Sleep-and-Wakeup-Magic-Functions-in-PHP-5/2/">their example code</a> they add the __sleep and __wake functions to the class they've been developing to output a string when the object is manipulated. These methods are automatically called when a <a href="http://php.net/serialize">serialize</a>/<a href="http://php.net/unserialize">unserialize</a> function call is made on the object.
</p>]]></description>
      <pubDate>Wed, 17 Jun 2009 08:49:19 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Stubbles Blog: Some remarks to serialization without pity]]></title>
      <guid>http://www.phpdeveloper.org/news/7485</guid>
      <link>http://www.phpdeveloper.org/news/7485</link>
      <description><![CDATA[<p>
In response to <a href="http://terrychay.com/blog/article/object-serialization-without-pity.shtml">Terry Chay's response</a> about his <a href="http://www.phpdeveloper.org/news/7453">previous blog post</a>, <i>Frank Kleine</i> has posted <a href="http://www.stubbles.org/archives/13-Some-remarks-to-serialization-without-pity.html">a few more comments</a> on the topic of object serialization and some of the assertions <i>Terry</i> made.
</p>
<blockquote>
<a href="http://terrychay.com/blog/article/object-serialization-without-pity.shtml">Terry Chay</a> made some remarks to <a href="http://www.stubbles.org/archives/12-Lazy-loading-of-classes-stored-in-a-session-without-__autoload.html">my last blog entry</a> about a solution for lazy class loading without using __autoload(). Some of his statements seem like I explained my implementation not good enough leading to wrong interpretations. In this blog entry I'll use some of his statements to take a deeper look into my implementation and show that he has drawed some conclusions which I want to disprove.
</blockquote>
<p>
He <a href="http://www.stubbles.org/archives/13-Some-remarks-to-serialization-without-pity.html">goes back</a> and corrects some of what <i>Terry</i> has said in his response, including showing a more detailed version of him implementation. Be sure to check out the comments for the post, though - <i>Terry</i> comes back and clarifies some of the comments he'd made including the framework talk and changes of perspective having seen the new code snippet/information.
</p>]]></description>
      <pubDate>Thu, 22 Mar 2007 10:39:00 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: Using the Sleep and Wakeup Functions to Serialize Objects in PHP  (Part 2)]]></title>
      <guid>http://www.phpdeveloper.org/news/5575</guid>
      <link>http://www.phpdeveloper.org/news/5575</link>
      <description><![CDATA[<p>
DevShed continues their "serializing objects" series today with <a href="http://www.devshed.com/c/a/PHP/Using-the-Sleep-and-Wakeup-Functions-to-Serialize-Objects-in-PHP">part two</a> of the series, highlighting the use of the sleep and wakeup functionality of PHP to help with the serialization.
</p>
<quote>
<i>
After refreshing the concepts that I deployed in the first part of this series, it's time to focus on the topics that I'll cover in this article, so you'll know what to expect before you continue reading. In this second part, I'll explain how to use objects in conjunction with the "__sleep()" and "__wakeup() magic functions respectively, in order to get the most out of them.
</i>
</quote>
<p>
They <a href="http://www.devshed.com/c/a/PHP/Using-the-Sleep-and-Wakeup-Functions-to-Serialize-Objects-in-PHP/">start with</a> a look at defining self-saving objects with their ObjectSaver class developed earlier. Building on that reminder, they integrate the "__sleep()" and "__wakeup()" functionality to handle calls immediately before and immediately after the handling of the object. They then use this new functionality to create persistent objects, capable of maintaining values across page requests.
</p>]]></description>
      <pubDate>Tue, 13 Jun 2006 08:11:34 -0500</pubDate>
    </item>
  </channel>
</rss>
