<?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 15:14:46 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[PHPMaster.com: Testing Error Conditions with PHPUnit]]></title>
      <guid>http://www.phpdeveloper.org/news/18543</guid>
      <link>http://www.phpdeveloper.org/news/18543</link>
      <description><![CDATA[<p>
Over on PHPMaster.com there's a new post for the unit testers in the audience (you all unit test, right?) from <i>Matt Turland</i> about <a href="http://phpmaster.com/testing-error-conditions-with-phpunit/">testing error conditions</a> in your applications.
</p>
<blockquote>
Let's say you're maintaining code that uses PHP's native trigger_error() function to log error information. Let's also say that you're in the process of <a href="http://phpmaster.com/getting-started-with-phpunit/">using PHPUnit</a> to write unit tests for that code. If you refer to the PHPUnit manual, there's a section that deals with <a href="http://www.phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.errors">testing for error condition</a>.  [...] However, depending on what your code looks like, it's possible that you'll run into a problem with PHPUnit's approach to this. This article will detail what this problem is, how it impacts your ability to test your code, and how to go about solving it.
</blockquote>
<p>
He points out that, since errors and exceptions handle differently, you have to work with them differently in your tests. PHPUnit has a feature that automatically turns errors into a specific type of exception when they're thrown and how, by using a simple custom error handler, you can more correctly tests error vs exception.
</p>]]></description>
      <pubDate>Tue, 02 Oct 2012 11:57:40 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Cory Fowler: Enabling PHP 5.4 in Windows Azure Web Sites]]></title>
      <guid>http://www.phpdeveloper.org/news/18502</guid>
      <link>http://www.phpdeveloper.org/news/18502</link>
      <description><![CDATA[<p>
<i>Cory Fowler</i> has a recent post explaining how you can enable one of the most recent PHP releases (PHP 5.4) on your Windows Azure website via the " Bring-Your-Own-Runtime" feature.
</p>
<blockquote>
Much like many other developers, I like to live on the bleeding edge, learning new language features, using the latest tools so naturally one of the things I wanted to see in <a href="http://www.windowsazure.com/">Windows Azure</a> Web Sites is support for PHP 5.4. I'm pleased to be telling you today in this post that support for Bring-Your-Own-Runtime is now available in Windows Azure Web Sites. Out of the box, Windows Azure Web Sites supports PHP 5.3 as you can see from the snapshot of the portal below. In this article I'll explain how to enable PHP 5.4 in Windows Azure Web Sites.
</blockquote>
<p>
You'll need to <a href="http://www.windowsazure.com/en-us/develop/php/">set up and configure</a> an Azure instance to work with (if you don't already have one) and navigate to its management Dashboard once complete. You can then setup a handler mapping that points to an uploaded version of the PHP Windows binary for 5.4 on your document root. Then all that's left is to upload (via FTP or git) this executable and you'll be all set.
</p>]]></description>
      <pubDate>Fri, 21 Sep 2012 08:09:21 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Amazon DynamoDB: Store PHP Sessions with Load Balancer]]></title>
      <guid>http://www.phpdeveloper.org/news/18474</guid>
      <link>http://www.phpdeveloper.org/news/18474</link>
      <description><![CDATA[<p>
PHPMaster.com has a new tutorial posted showing how you can <a href="http://phpmaster.com/amazon-dynamodb-store-php-sessions-with-load-balancer/">work with the Amazon DynamoDB</a> to store session information from your PHP application (originally posted on <a href="http://cloudspring.com/">CloudSpring</a>).
</p>
<blockquote>
This tutorial will show you how to use Amazon DynamoDB as a storage facility for PHP sessions. This method becomes very useful when your applications take advantage of the Elastic Load Balancing and Autoscaling services. You will need Amazon AWS account enabled to use EC2, Elastic Load Balancer and DynamoDB as a prerequisite to play along the tutorial.
</blockquote>
<p>
He starts with a description of what the elastic load balancing service is and how it autoscales. He shows how, based on <a href="https://github.com/cloudspring/AWSDynamoDBSession_PHP">this demo application</a>, to use a custom PHP session handler that implements the Amazon SDK libraries to hook into the DynamoDB service. Also included are screenshots (and the steps that go with them) to configure the service itself.
</p>]]></description>
      <pubDate>Thu, 13 Sep 2012 11:19:57 -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[Lorna Mitchell's Blog: Building A RESTful PHP Server: Output Handlers]]></title>
      <guid>http://www.phpdeveloper.org/news/17478</guid>
      <link>http://www.phpdeveloper.org/news/17478</link>
      <description><![CDATA[<p>
<i>Lorna Mitchell</i> is back with another post in her "Building a RESTful PHP Server" series today with <a href="http://www.lornajane.net/posts/2012/building-a-restful-php-server-output-handlers">this new post</a> showing how to work with output handlers (her focus is on JSON).
</p>
<blockquote>
So far we've covered parsing requests to determine exactly what the user is asking for, and also looked at routing to a controller to obtain the data or perform the action required. This post gives examples of how to return the data to the client in a good way.
</blockquote>
<p>
She advocates using output handlers instead of the usual views you'd think of in a typical MVCish sort of application. The difference here is that there's not a lot of extra overhead to produce the results - it's literally an output directly from a class extending the base view (including the correct headers). She also briefly mentions the inclusion of <a href="http://en.wikipedia.org/wiki/JSONP">JSONP</a> functionality, allowing you to specify a local callback to execute when the request is returned. A few other "nice to haves" are also mentioned like the number of results returned and pagination support.
</p>]]></description>
      <pubDate>Wed, 01 Feb 2012 10:25:33 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Writing Custom Session Handlers]]></title>
      <guid>http://www.phpdeveloper.org/news/17319</guid>
      <link>http://www.phpdeveloper.org/news/17319</link>
      <description><![CDATA[<p>
On PHPMaster.com today there's a new post showing you how to <a href="http://phpmaster.com/writing-custom-session-handlers/">write custom session handlers</a> - in their case, a database-based option that can span across multiple servers/services.
</p>
<blockquote>
Sessions are a tool which helps the web programmer overcome the stateless nature of the internet. You can use them to build shopping carts, monitor visits to a website, and even track how a user navigates through your application. PHP's default session handling behavior can provide all you need in most cases, but there may be times when you want to expand the functionality and store session data differently. This article will show you how the default functionality works and then goes on to show you how override it to provide a custom solution.
</blockquote>
<p>
They introduce how sessions are stored normally (based on the save path) and what the serialized contents of it would look like. They show you how to take this, normally stored on the local file system, and change it to be written to a "session" table in a MySQL database (via <a href="http://php.net/pdo">PDO</a>). It includes reading, writing, updating and some garbage collection to clean out old values from the table.
</p>]]></description>
      <pubDate>Thu, 29 Dec 2011 09:41:25 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Error Handling in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17110</guid>
      <link>http://www.phpdeveloper.org/news/17110</link>
      <description><![CDATA[<p>
On PHPMaster.com today there's a new tutorial from <i>Sneha Heda</i> looking at <a href="http://phpmaster.com/error-handling-in-php/">error handling in PHP</a> - the types of errors that can come up, how to throw your own and how to catch them appropriately.
</p>
<blockquote>
Errors are the most common event a developer faces when programming. [...] To help reduce the number of errors in your code, and to mitigate their effects, proper error handling is essential in your web application. This article is a crash course in PHP error handling. You'll learn about PHP's built-in error reporting levels, and how to handle errors with custom error handlers and exception handling.
</blockquote>
<p>
She starts with the different error reporting levels PHP offers, everything from the lightweight E_NOTICE out to E_ALL|E_STRICT. With this as a reference, she shows how to create a custom error handler (using <a href="http://php.net/set_error_handler">set_error_handler</a>). Also included is a look at exceptions and some of the more detailed information that comes with them - line numbers, messages, file the error was thrown from, etc.
</p>]]></description>
      <pubDate>Thu, 10 Nov 2011 08:41:39 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Gonzalo Ayuso's Blog: Display errors on screen even with display errors = off with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16977</guid>
      <link>http://www.phpdeveloper.org/news/16977</link>
      <description><![CDATA[<p>
<i>Gonzalo Ayuso</i> has posted a handy tip to his blog today about <a href="http://gonzalo123.wordpress.com/2011/10/10/display-errors-on-screen-even-with-display-errors-off-in-php/">showing errors even with "display_errors" being off</a> in your application (could be helpful in debugging those difficult problems).
</p>
<blockquote>
 Shared hosting are cheap, but normally they don't allow us the use some kind of features. For example we cannot see the error log. That's a problem when we need to see what happens within our application. Normally I work with my own servers, and I have got full access to error logs. But if we cannot see the error log and the server is configured with <a href="http://es.php.net/manual/en/errorfunc.configuration.php#ini.display-errors">display errors = off</a> in php.ini (typical configuration in shared hosting), we have a problem.
</blockquote>
<p>
His solution involves an "error sniffer" script that captures the issues in a script and echoes them out at the end. In <a href="https://github.com/gonzalo123/ErrorSniffer">his ErrorSniffer</a> he sets up a custom error, exception and shutdown handler to grab the problems and capture them for later use - including echoing them out to the user if desired.
</p>]]></description>
      <pubDate>Tue, 11 Oct 2011 11:03:07 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[David Stockton's Blog: Changing ErrorController to work with AJAX]]></title>
      <guid>http://www.phpdeveloper.org/news/16709</guid>
      <link>http://www.phpdeveloper.org/news/16709</link>
      <description><![CDATA[<p>
<i>David Stockton</i> has a new tutorial posted to his blog - a technique he's found useful in his Zend Framework application to make the <a href="http://zendtutorials.com/tutorial/changing-errorcontroller-to-work-with-ajax/">ErrorController work with Ajax calls</a> to reduce the message you get back to just a JSON response.
</p>
<blockquote>
If you've ever built a Zend Framework MVC app which makes AJAX calls, you may have noticed that if an error occurs, you'll get a chunk of JSON followed by the HTML for the error page. If you've built a layout, you'll get all of that back to. This is fine if your users hit the page in the browser but it can cause problems with your JavaScript being able to correctly decode your JSON.
</blockquote>
<p>
The fix is pretty simple, though, and only requires that you add the error handling action to the Ajax context to force it to drop the layout and any other HTML that might come along with the view. He includes a bit more code to have the error handler include the exceptions and pass them out to be included in the JSON response.
</p>]]></description>
      <pubDate>Fri, 12 Aug 2011 08:58:06 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Gonzalo Ayuso's Blog: Using node.js to store PHP sessions]]></title>
      <guid>http://www.phpdeveloper.org/news/16627</guid>
      <link>http://www.phpdeveloper.org/news/16627</link>
      <description><![CDATA[<p>
<i>Gonzalo Ayuso</i> has an <a href="http://gonzalo123.wordpress.com/2011/07/25/using-node-js-to-store-php-sessions/">interesting new post</a> today looking at how to go cross-technology in your application and store your PHP sessions in a basic Node.js instance.
</p>
<blockquote>
We use <a href="http://www.php.net/manual/en/book.session.php">sessions</a> when we want to preserve certain data across subsequent accesses. PHP allows us to use different handlers when we're using sessions. The default one is filesystem, but we can change it with <A href="http://www.php.net/manual/en/session.configuration.php#ini.session.save-handler">session.save_handler</a> in the php.ini. session.save_handler defines the name of the handler which is used for storing and retrieving data associated with a session. We also can create our own handler to manage sessions. In this post we're going to create a custom handler to store sessions in a node.js service.
</blockquote>
<p>
He includes the full code you'll need (also <a href="https://github.com/gonzalo123/nodePhpSessions">here</a> on github) to make a custom session handling class on the PHP side and some simple unit tests done on the Node.js side to ensure for proper handling and garbage collection.
</p>]]></description>
      <pubDate>Mon, 25 Jul 2011 11:43:45 -0500</pubDate>
    </item>
  </channel>
</rss>
