<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>Derick Rethans - tag: cms</title>
    <link>http://derickrethans.nl/feed-cms.xml</link>
    <description>This feed shows the latest 15 items with the tag cms</description>
    <language>en-us</language>
    <copyright>All rights reserved - Derick Rethans</copyright>
    <managingEditor>derick@derickrethans.nl (Derick Rethans)</managingEditor>
    <pubDate>Sun, 18 Dec 2011 09:30:06 +0000</pubDate>
    <lastBuildDate>Sun, 18 Dec 2011 09:30:06 +0000</lastBuildDate>
    <generator>eZ Components Feed dev (http://ezcomponents.org/docs/tutorials/Feed)</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>60</ttl>
    <item>
      <title>Xdebug 2.1</title>
      <link>http://derickrethans.nl/xdebug-2.1-released.html</link>
      <description>&lt;div class="article"&gt;
  &lt;div class="body"&gt;
    &lt;div class="articleListItem"&gt;
      &lt;h1&gt;&lt;a name="xdebug_2_1"/&gt;Xdebug 2.1&lt;/h1&gt;
      &lt;dl class="head"/&gt;
      &lt;div class="articleMetaData"&gt;
        &lt;div class="location"&gt; London, UK&lt;/div&gt;
        &lt;div class="date"&gt;Tuesday, June 29th 2010, 15:17 BST&lt;/div&gt;
      &lt;/div&gt;
      &lt;img src="http://derickrethans.nl/images/content/xdebug_logo.png" class="right" alt="xdebug_logo.png"/&gt;
      &lt;p&gt;I've just released &lt;a href="http://xdebug.org"&gt;Xdebug&lt;/a&gt; 2.1. This new release contains all the bug fixes and new features that have been developed over the past three years. It provides full PHP 5.3 support, but it no longer supports PHP versions below 5.1.&lt;/p&gt;
      &lt;p&gt;A description of all the new features follows:&lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;Error Collection&lt;/strong&gt;
      &lt;/p&gt;
      &lt;p&gt;I've added xdebug_start_error_collection(), xdebug_stop_error_collection() and xdebug_get_collected_errors(), which allow you to collect all notices, warnings and error messages that Xdebug generates from PHP's error_reporting functionality so that you can output them at a later point in your script by hand.&lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;Header Setting Interception&lt;/strong&gt;
      &lt;/p&gt;
      &lt;p&gt;All functions that set HTTP headers such as with &lt;a href="http://php.net/header"&gt;header()&lt;/a&gt; and &lt;a href="http://php.net/setcookie"&gt;setcookie()&lt;/a&gt; are now intercepted by Xdebug. The intercepted headers are stored internally in an array that can be retrieved by calling the &lt;a href="http://xdebug.org/docs/all_functions#xdebug_get_headers"&gt;xdebug_get_headers()&lt;/a&gt; function. This is very useful in cases where you need to test certain functionality that sets headers somewhere deep in code. This function is also used in &lt;a href="http://ezcomponents.org"&gt;eZ Components'&lt;/a&gt; test suite to &lt;a href="http://svn.ez.no/svn/ezcomponents/trunk/MvcTools/tests/response_writers/http.php"&gt;test&lt;/a&gt; whether the correct HTTP headers are set in the &lt;a href="http://ezcomponents.org/s/MvcTools"&gt;MvcTools&lt;/a&gt; component.&lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;Variable Assignment Tracing&lt;/strong&gt;
      &lt;/p&gt;
      &lt;p&gt;The new setting &lt;a href="http://xdebug.org/docs/all_settings#collect_assignments"&gt;xdebug.collect_assignments&lt;/a&gt; allows you to record changes to variables in scripts to &lt;a href="http://xdebug.org/docs/execution_trace"&gt;trace files&lt;/a&gt;.  I've already written more about it in &lt;a href="http://derickrethans.nl/variable-tracing-with-xdebug.html"&gt;Variable tracing with Xdebug&lt;/a&gt;.&lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;"Scream" Support&lt;/strong&gt;
      &lt;/p&gt;
      &lt;p&gt;The &lt;a href="http://pecl.php.net/scream"&gt;scream&lt;/a&gt; PECL extension disables the &lt;code&gt;@&lt;/code&gt; (shut-up) operator to actually see all notices, warnings and errors that PHP generates. The scream extension's functionality have been duplicated as Xdebug's &lt;a href="http://xdebug.org/docs/all_settings#scream"&gt;xdebug.scream&lt;/a&gt; php.ini setting. Why disabling the @-operator is a good thing, I've already outlined in &lt;a href="http://derickrethans.nl/five-reasons-why-the-shutop-operator-should-be-avoided.html"&gt;Five reasons why the shut-op operator (@) should be avoided&lt;/a&gt;.&lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;Additions for Stack Traces&lt;/strong&gt;
      &lt;/p&gt;
      &lt;p&gt;All HTML containers generated by Xdebug (error messages, &lt;a href="http://xdebug.org/docs/all_functions#xdebug_var_dump"&gt;xdebug_var_dump()&lt;/a&gt; output) now contain a CSS class for easier styling.&lt;/p&gt;
      &lt;p&gt;The new setting &lt;a href="http://xdebug.org/docs/all_settings#file_link_format"&gt;xdebug.file_link_format&lt;/a&gt; allows you to turn any file/line link in Xdebug's output to be decorated to a link with a specific format.  For example you can set it to &lt;code&gt;txmt://open/?file://%f&amp;line=%l&lt;/code&gt; for opening files directly in Textmate, or &lt;code&gt;gvim://%f@%l&lt;/code&gt; with some shell script for gvim and Firefox.&lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;Remote Debugging&lt;/strong&gt;
      &lt;/p&gt;
      &lt;p&gt;The new setting &lt;a href="http://xdebug.org/docs/all_settings#remote_connect_back"&gt;xdebug.remote_connect_back&lt;/a&gt;, contributed by Lucas Nealan and Brian Shire, allows Xdebug to try to make a debugging connection to the IP address from which the browser request came from. This setting is an additional solution for &lt;a href="http://derickrethans.nl/debugging-with-multiple-users.html"&gt;debugging with multiple users&lt;/a&gt;.&lt;/p&gt;
      &lt;p&gt;The old &lt;code&gt;gdb&lt;/code&gt; and &lt;code&gt;php3&lt;/code&gt; remote debugging engines have been removed.&lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;Overloaded var_dump&lt;/strong&gt;
      &lt;/p&gt;
      &lt;p&gt;The newly introduced setting xdebug.overload_var_dump can be used to turn off Xdebug's default behavior of overriding PHP's &lt;a href="http://php.net/var_dump"&gt;var_dump()&lt;/a&gt; function with the &lt;a href="http://xdebug.org/docs/all_functions#xdebug_var_dump"&gt;xdebug_var_dump()&lt;/a&gt; function that uses pretty HTML for formatting a variable structure. It does not stop &lt;a href="http://xdebug.org/docs/all_functions#xdebug_var_dump"&gt;xdebug_var_dump()&lt;/a&gt; from working however.&lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;Donations&lt;/strong&gt;
      &lt;/p&gt;
      &lt;p&gt;You can probably imagine that writing and support Xdebug is a time-consuming effort. It's a tool that saves a lot of work during developement of applications, as well while debugging.  If you think Xdebug is valuable for you, perhaps you would like to consider a &lt;a href="http://xdebug.org/donate.php"&gt;donation&lt;/a&gt;. All donations are greatly appreciated and support future development and availablity of Xdebug.&lt;/p&gt;
      &lt;p&gt;If you want to sponsor a (new) feature in Xdebug, feel free to &lt;a href="mailto:derick@xdebug.org"&gt;contact&lt;/a&gt; me as well.&lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;Download and Support&lt;/strong&gt;
      &lt;/p&gt;
      &lt;p&gt;The new version of Xdebug can be downloaded through the &lt;a href="http://xdebug.org/download.php"&gt;download&lt;/a&gt; page. A list with all changes can be found on the &lt;a href="http://xdebug.org/updates.php#x_2_1_0"&gt;updates&lt;/a&gt; page. Support information can be found on the &lt;a href="http://xdebug.org/support.php"&gt;support&lt;/a&gt; page, and issues and feature requests can be filed in the &lt;a href="http://bugs.xdebug.org"&gt;bug tracker&lt;/a&gt;. Before asking for support, please have a look at the &lt;a href="http://xdebug.org/docs/faq"&gt;FAQ&lt;/a&gt; first.&lt;/p&gt;
      
      
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</description>
      <guid>201006291449</guid>
      <pubDate>Tue, 29 Jun 2010 14:17:00 +0000</pubDate>
    </item>
    <item>
      <title>Xdebug 2.1.0 RC1 released</title>
      <link>http://derickrethans.nl/xdebug-2.1.0rc1-released.html</link>
      <description>&lt;div class="article"&gt;
  &lt;div class="body"&gt;
    &lt;div class="articleListItem"&gt;
      &lt;h1&gt;&lt;a name="xdebug_2_1_0_rc1_released"/&gt;Xdebug 2.1.0 RC1 released&lt;/h1&gt;
      &lt;dl class="head"/&gt;
      &lt;div class="articleMetaData"&gt;
        &lt;div class="location"&gt; Schiphol, Netherlands&lt;/div&gt;
        &lt;div class="date"&gt;Tuesday, April 6th 2010, 15:41 CEST&lt;/div&gt;
      &lt;/div&gt;
      &lt;p&gt;As earlier announced in my April Fools' &lt;a href="http://derickrethans.nl/xdebug-will-cost-money.html"&gt;announcement&lt;/a&gt; and on Xdebug's &lt;a href="http://twitter.com/xdebug/status/11687180290"&gt;twitter&lt;/a&gt; feed, I'm now releasing &lt;a href="http://xdebug.org"&gt;Xdebug&lt;/a&gt; 2.1.0RC1. This is the first Release Candidate and it addresses a number of &lt;a href="http://xdebug.org/updates.php#x_2_1_0rc1"&gt;issues&lt;/a&gt; found in the latest beta. As I usually do in release announcements, I will also be introducing a new feature in Xdebug 2.1 in this one.&lt;/p&gt;
      &lt;p&gt;In an &lt;a href="http://derickrethans.nl/five-reasons-why-the-shutop-operator-should-be-avoided.html"&gt;article&lt;/a&gt; that I wrote a few months ago, I illustrated a few different reasons on why the shut-op operator (&lt;code&gt;@&lt;/code&gt;) should be avoided. Although there are a few cases where it simple can not be avoided if you want to write notice-free code, the main reason why this operator should be avoided, is because it makes debugging quite a bit more difficult if errors are hidden.&lt;/p&gt;
      &lt;p&gt;Xdebug is a debugging aid to make debugging easier. So from version 2.1.0 there is a new configuration setting — &lt;code&gt;xdebug.scream&lt;/code&gt; — that simply disables the effects of the &lt;code&gt;@&lt;/code&gt; operator. That means that all errors will be shown, of course, still listening to the &lt;code&gt;error_reporting&lt;/code&gt; and &lt;code&gt;display_errors&lt;/code&gt; settings. This functionality is not a novel thing, and the idea was lifted from the PECL &lt;a href="http://pecl.php.net/scream"&gt;scream&lt;/a&gt; package. However, I think this functionality fits in very well with all the other things that Xdebug has to offer.&lt;/p&gt;
      &lt;p&gt;Just to mention it once more, I have no intention of making Xdebug closed source. I spend a considerable amount of time in adding new features and addressing issues, so I would appreciate it that if consider a &lt;a href="http://xdebug.org/donate.php"&gt;donation&lt;/a&gt; in case Xdebug has saved you time and effort in debugging your application. If you have comments or suggestions to improve Xdebug, please write to the &lt;a href="http://xdebug.org/support.php#list"&gt;mailinglist&lt;/a&gt;.&lt;/p&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</description>
      <guid>201004061541</guid>
      <pubDate>Tue, 06 Apr 2010 13:41:00 +0000</pubDate>
    </item>
    <item>
      <title>First release of the D-Bus extension</title>
      <link>http://derickrethans.nl/dbus-extension-released.html</link>
      <description>&lt;div class="article"&gt;
  &lt;div class="body"&gt;
    &lt;div class="articleListItem"&gt;
      &lt;h1&gt;&lt;a name="first_release_of_the_d-bus_extension"/&gt;First release of the D-Bus extension&lt;/h1&gt;
      &lt;dl class="head"/&gt;
      &lt;div class="articleMetaData"&gt;
        &lt;div class="location"&gt; London, UK&lt;/div&gt;
        &lt;div class="date"&gt;Tuesday, April 6th 2010, 10:33 BST&lt;/div&gt;
      &lt;/div&gt;
      &lt;p&gt;A few days ago I made the first beta release of the &lt;a href="http://pecl.php.net/package/dbus"&gt;D-Bus extension&lt;/a&gt; that I have been working on for a while. &lt;a href="http://www.freedesktop.org/wiki/Software/dbus"&gt;D-Bus&lt;/a&gt; is a message bus system, a simple way for applications to talk to one another. I started working on this because my cellphone, an OpenMoko &lt;a href="http://www.openmoko.com/freerunner.html"&gt;FreeRunner&lt;/a&gt;. This cellphone (or rather, a mobile Linux computing device) implements &lt;a href="http://www.freesmartphone.org/"&gt;freesmartphone.org&lt;/a&gt; APIs to talk to all the hardware that is available on the device. This includes GSM and SIM card interfaces, but also GPS, Audio and PIM services.&lt;/p&gt;
      &lt;p&gt;However, many other applications on the Linux desktop speak D-Bus. This includes system services such as the notification daemon, the screen saver and hardware plug-in detection as well as desktop applications such as &lt;a href="http://www.pidgin.im/"&gt;Pidgin&lt;/a&gt; and &lt;a href="http://live.gnome.org/Empathya"&gt;Empathy&lt;/a&gt;.&lt;/p&gt;
      &lt;p&gt;I've given a &lt;a href="http://derickrethans.nl/talks/dbus-london2010.pdf"&gt;presentation&lt;/a&gt; on the extension at the &lt;a href="http://www.phpconference.co.uk/"&gt;PHP London conference&lt;/a&gt; earlier this year, and will also be speaking on this subject as part of the "PHP Inside" and "PHP on the D-Bus" talks at &lt;a href="http://tek.phparch.com/schedule/"&gt;Tek-X&lt;/a&gt; (Chicago, May 18-21), &lt;a href="http://it-republik.de/php/phpconference2010se/"&gt;International PHP Conference Spring&lt;/a&gt; (Berlin, May 30-June 2) and the &lt;a href="http://phpconference.nl/"&gt;Dutch PHP Conference&lt;/a&gt; (June 10-12).&lt;/p&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</description>
      <guid>201004060920</guid>
      <pubDate>Tue, 06 Apr 2010 09:33:00 +0000</pubDate>
    </item>
    <item>
      <title>Xdebug no longer Open Source</title>
      <link>http://derickrethans.nl/xdebug-will-cost-money.html</link>
      <description>&lt;div class="article"&gt;
  &lt;div class="body"&gt;
    &lt;div class="articleListItem"&gt;
      &lt;h1&gt;&lt;a name="xdebug_no_longer_open_source"/&gt;Xdebug no longer Open Source&lt;/h1&gt;
      &lt;dl class="head"/&gt;
      &lt;div class="articleMetaData"&gt;
        &lt;div class="location"&gt; London, UK&lt;/div&gt;
        &lt;div class="date"&gt;Thursday, April 1st 2010, 10:19 BST&lt;/div&gt;
      &lt;/div&gt;
      &lt;p&gt;
        &lt;strong&gt;This was obviously an April Fools' joke, Xdebug will continue to stay Open Source and free of charge.&lt;/strong&gt;
      &lt;/p&gt;
      &lt;p&gt;Later today I will be releasing the first Release Candidate of Xdebug 2.1. With regret I have to announce that from this release, I will no longer provide Xdebug as an open source debugger extension. I've noticed that there are other projects making money of Xdebug's success while I only receive &lt;a href="http://xdebug.org/donate.php"&gt;donations&lt;/a&gt; from a group of awesome supporters.&lt;/p&gt;
      &lt;p&gt;Xdebug will continue to be available for benefactors on a limited number of platforms that I have access to (Linux 32/64bit and Windows). Please refer to the &lt;a href="http://derickrethans.nl/files/dump/faq.html"&gt;FAQ&lt;/a&gt; for further information.&lt;/p&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</description>
      <guid>201004011019</guid>
      <pubDate>Thu, 01 Apr 2010 09:19:00 +0000</pubDate>
    </item>
    <item>
      <title>Storing Date/Times in Databases</title>
      <link>http://derickrethans.nl/storing-date-time-in-database.html</link>
      <description>&lt;div class="article"&gt;
  &lt;div class="body"&gt;
    &lt;div class="articleListItem"&gt;
      &lt;h1&gt;&lt;a name="storing_date_times_in_databases"/&gt;Storing Date/Times in Databases&lt;/h1&gt;
      &lt;dl class="head"/&gt;
      &lt;div class="articleMetaData"&gt;
        &lt;div class="location"&gt; London, UK&lt;/div&gt;
        &lt;div class="date"&gt;Monday, March 29th 2010, 16:47 BST&lt;/div&gt;
      &lt;/div&gt;
      &lt;p&gt;After my talk during &lt;a href="http://confoo.ca/en"&gt;ConFoo&lt;/a&gt; on &lt;a href="http://confoo.ca/en/2010/session/advanced-date-time-handling-with-php"&gt;Advanced Date/Time Handling&lt;/a&gt; I received a question about whether the UTC-offset, together with the date/time in years, months, days, hours, minutes and seconds, was enough for storing a date/time in a database and still being able to do calculations with this. The answer to this question was no, but it lead to an even more interesting discussion about what &lt;em&gt;would&lt;/em&gt; be enough to store an accurate date/time in a database.&lt;/p&gt;
      &lt;p&gt;Firstly let me explain why storing a UTC offset is not adequate at all for doing any sort of calculations. Right now (March 25th, 2010), Montreal is on the same time as Santiago (in Chile) with both a UTC offset of -4 hours. This means that for the same date/time (&lt;code&gt;2010-03-25
19:03&lt;/code&gt;) the same timestamp is generated (&lt;code&gt;1269558180&lt;/code&gt;). However if we want to add eight months (&lt;code&gt;2010-11-25 19:03&lt;/code&gt;) to the current time for each of those locations then the timestamps &lt;em&gt;should&lt;/em&gt; be different — &lt;code&gt;1290729780&lt;/code&gt; for Montreal and &lt;code&gt;1290722580&lt;/code&gt; for Santiago. It turns out that &lt;em&gt;neither&lt;/em&gt; of them is exactly a full 24 hour difference from &lt;code&gt;2010-03-25 19:03&lt;/code&gt; as is shown the following script:&lt;/p&gt;
      &lt;pre&gt;&lt;?php
$s = '2010-03-25 19:03';
$montrealNow = date_create( "{$s} America/Montreal" )-&gt;format( 'U' );
$santiagoNow = date_create( "{$s} America/Santiago" )-&gt;format( 'U' );
$s = '2010-11-25 19:03';
$montrealThen = date_create( "{$s} America/Montreal" )-&gt;format( 'U' );
$santiagoThen = date_create( "{$s} America/Santiago" )-&gt;format( 'U' );

$hour = 60 * 60;
$day = 24 * $hour;

echo "Montreal:\n",
    $montrealNow, " - ",
    $montrealThen, "\n",
    ( ( $montrealThen - $montrealNow ) % $day ) / $hour, "\n\n";

echo "Santiago:\n",
    $santiagoNow, " - ",
    $santiagoThen, "\n",
    ( ( $santiagoThen - $santiagoNow ) % $day ) / $hour, "\n\n";

?&gt;

&lt;/pre&gt;
      &lt;p&gt;which gives the output:&lt;/p&gt;
      &lt;pre&gt;Montreal:
1269558180 - 1290729780
1

Santiago:
1269558180 - 1290722580
23

&lt;/pre&gt;
      &lt;p&gt;From this we see that Montreal has an extra hour and Santiago has an hour less. This is because Montreal changed from Daylight Savings Time to normal time and Santiago, being on the southern hemisphere, moved from normal time to Daylight Savings time.&lt;/p&gt;
      &lt;p&gt;Now if we had only the timestamp (&lt;code&gt;1269558180&lt;/code&gt;) and the UTC-offset, the only thing we could do would be to advance a specific number of days. In this case, there are 245 days, which makes (&lt;code&gt;245 * 24 * 60 * 60 =&lt;/code&gt; ) &lt;code&gt;21168000&lt;/code&gt; seconds. If we add this to the original timestamp, we end up at &lt;code&gt;1290726180&lt;/code&gt; which corresponds to &lt;code&gt;2010-11-25 18:03&lt;/code&gt; Montreal time, or &lt;code&gt;2010-11-25 20:03&lt;/code&gt; Santiago time. Neither of them being the correct &lt;code&gt;2010-11-25 19:03&lt;/code&gt;. Because from the UTC offset of 4 hours we don't know whether we're in Montreal or Santiago, we can conclude that with just this UTC offset and the original timestamp we can't calculate the timestamp of something that's 8 months in the future. Storing the UTC-offset can not change this fact either.&lt;/p&gt;
      &lt;p&gt;In order to to proper calculations, you need to keep information about the timezone itself. In PHP timezones are identified with identifiers such as &lt;code&gt;America/Montreal&lt;/code&gt;. If we store those alongside the timestamps, we can do the proper calculations. The following example demonstrates that:&lt;/p&gt;
      &lt;pre&gt;&lt;?php
$timestamp = 1269558180;
$tzid      = 'America/Montreal';

$d = new DateTime( "@$timestamp" );
$d-&gt;setTimeZone( new DateTimeZone( $tzid ) );
$d-&gt;modify( '+8 months' );

echo $d-&gt;format( 'Y-m-d H:i' ), "\n";
?&gt;

&lt;/pre&gt;
      &lt;p&gt;which gives the output: &lt;code&gt;2010-11-25 19:03&lt;/code&gt;.&lt;/p&gt;
      &lt;p&gt;This seems to work, but unfortunately, even the approach of storing the timestamp and timezone identifier is not going to work correctly under certain circumstances. In order to find out why, we have to go back to January this year.&lt;/p&gt;
      &lt;p&gt;Imagine that in January this year—January 15th to be precise—we run the following script to determine the timestamp of a date/time two months in the future:&lt;/p&gt;
      &lt;pre&gt;&lt;?php
$tz = 'America/Santiago';
$ts = date_create( "2010-01-15 10:41 $tz" )-&gt;format( 'U' );

$d = new DateTime( "@$ts" );
$d-&gt;setTimeZone( new DateTimeZone( $tz ) );
$d-&gt;modify( '+2 months' );

echo $d-&gt;format( 'U Y-m-d H:i' ), "\n";
?&gt;

&lt;/pre&gt;
      &lt;p&gt;This returns the timestamp &lt;code&gt;1268664060&lt;/code&gt; for the date/time &lt;code&gt;2010-03-15
10:41:00&lt;/code&gt;.&lt;/p&gt;
      &lt;p&gt;Now skip forwards to the current date and time. If we used this calculated timestamp and the timezone identifier &lt;code&gt;America/Santiago&lt;/code&gt; today to generate a date/time string, we would however get a different output. The following example shows this:&lt;/p&gt;
      &lt;pre&gt;&lt;?php
$tz = 'America/Santiago';
$d = date_create( "@1268664060" );
$d-&gt;setTimeZone( new DateTimeZone( $tz ) );

echo $d-&gt;format( 'Y-m-d H:i:s' ), "\n";
?&gt;

&lt;/pre&gt;
      &lt;p&gt;which gives the output: &lt;code&gt;2010-03-15 11:41:00&lt;/code&gt; (and not &lt;code&gt;2010-03-15
10:41:00&lt;/code&gt;).&lt;/p&gt;
      &lt;p&gt;The difference in output is not a bug, but is caused because some countries change Daylight Savings Time rules quite frequently. In this case Chile decided (on March 4th) that instead of going forwards to DST at midnight March 14th, they will delay that to April 4th. When we ran the code on January 15th, the rules still thought that March 15th would already be on normal time again, outside of DST. But running the code now, with the updated rule set, we find that DST is still in effect until April 4th. The following example shows the transitions from/to DST for Santiago in 2010:&lt;/p&gt;
      &lt;pre&gt;&lt;?php
$tzid = "America/Santiago";

$tz = new DateTimeZone( $tzid );
$transitions = $tz-&gt;getTransitions(
    strtotime( '2010-01-01 00:00 UTC' ),
    strtotime( '2010-12-31 00:00 UTC' )
);

foreach ( $transitions as $t )
{
    echo $t['time'], ' ', $t['offset'] / 3600, ' ', $t['abbr'], "\n";
}
?&gt;

&lt;/pre&gt;
      &lt;p&gt;If we run this script with PHP 5.3.1 or 5.3.2—which still have the old incorrect rule set—the output is:&lt;/p&gt;
      &lt;pre&gt;2010-01-01T00:00:00+0000 -3 CLST
2010-03-14T03:00:00+0000 -4 CLT
2010-10-10T04:00:00+0000 -3 CLST

&lt;/pre&gt;
      &lt;p&gt;In the SVN repository, the rule set has been updated, so snapshots of PHP 5.3-dev have the correct rules and the script will show:&lt;/p&gt;
      &lt;pre&gt;2010-01-01T00:00:00+0000 -3 CLST
2010-04-04T03:00:00+0000 -4 CLT
2010-10-10T04:00:00+0000 -3 CLST

&lt;/pre&gt;
      &lt;p&gt;This leads to the conclusion that storing timestamps and timezone identifiers is not good enough either, unless you want an &lt;em&gt;exact&lt;/em&gt; point in time, as opposed to the more expected date/time in a location. So how &lt;em&gt;should&lt;/em&gt; you store the latter then? Basically, in the same way that DateTime objects are serialized in PHP 5.3. Let us imagine again, that the following code is run on January 15th again:&lt;/p&gt;
      &lt;pre&gt;&lt;?php
$tzid = 'America/Santiago';
$d = new DateTime( "2010-01-15 10:41 $tzid" );
$d-&gt;modify( '+2 months' );
$s = $d-&gt;format( 'Y-m-d H:i:s' );
$ts = $d-&gt;format( 'U' );
echo "$s (ts=$ts)\n";
?&gt;

&lt;/pre&gt;
      &lt;p&gt;which gives the output &lt;code&gt;2010-03-15 10:41:00 (ts=1268664060)&lt;/code&gt;. The next example is run with a recent rule set (such as in PHP SVN) today:&lt;/p&gt;
      &lt;pre&gt;&lt;?php
$tzid = 'America/Santiago';
$d = new DateTime( "$s $tzid" );
$s = $d-&gt;format( 'Y-m-d H:i:s' );
$ts = $d-&gt;format( 'U' );
echo "$s (ts=$ts)\n";
?&gt;

&lt;/pre&gt;
      &lt;p&gt;which gives the output &lt;code&gt;2010-03-15 10:41:00 (ts=1268660460)&lt;/code&gt;. As you can see, now the date/time itself is correct, although there is a different timestamp. PHP's DateTime serialisation does something similar:&lt;/p&gt;
      &lt;pre&gt;&lt;?php
$d = new DateTime();
$d-&gt;setTimeZone( new DateTimeZone( 'America/Santiago' ) );
var_dump( $d );
?&gt;

&lt;/pre&gt;
      &lt;p&gt;which gives the output:&lt;/p&gt;
      &lt;pre&gt;object(DateTime)#1 (3) {
  ["date"]=&gt;
  string(19) "2010-03-29 11:32:08"
  ["timezone_type"]=&gt;
  int(3)
  ["timezone"]=&gt;
  string(16) "America/Santiago"
}

&lt;/pre&gt;
      &lt;p&gt;For things to work correctly, you need to have an up-to-date rule set. PHP versions are not released as often as the timezonedb (sometimes more than 20 times a year) and to address this issue you can install the pecl extension &lt;a href="http://pecl.php.net/package/timezonedb"&gt;timezonedb&lt;/a&gt; with &lt;code&gt;pecl install timezonedb&lt;/code&gt;.&lt;/p&gt;
      &lt;p&gt;To store information in a database, I would use a &lt;code&gt;char&lt;/code&gt; column-type to store the whole &lt;code&gt;America/Santiago&lt;/code&gt; timezone identifier and another &lt;code&gt;char&lt;/code&gt; column-type to store the date/time (in the &lt;code&gt;yyyy-mm-dd
hh:ii:ss&lt;/code&gt; format).  Alternatively, you can pick a 'datetime' column-type, as long as that type &lt;strong&gt;ignores&lt;/strong&gt; timezones altogether. For MySQL that is the &lt;code&gt;DATETIME&lt;/code&gt; column-type, and for PostgreSQL the &lt;code&gt;TIMESTAMP&lt;/code&gt; or &lt;code&gt;TIMESTAMP WITHOUT TIME ZONE&lt;/code&gt; column-types.&lt;/p&gt;
      &lt;p&gt;Databases rarely handle timezones, daylight savings time and rule changes correctly, so avoid the database specific functionality all together. Using either a &lt;code&gt;char&lt;/code&gt; or a timezone-less 'datetime' column-type would still allow you to sort and by using a 'datetime' column-type you can even do calculations.&lt;/p&gt;
      &lt;p&gt;Happy summer time!&lt;/p&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</description>
      <guid>201003291647</guid>
      <pubDate>Mon, 29 Mar 2010 15:47:00 +0000</pubDate>
    </item>
    <item>
      <title>Available for PHP Extension Writing</title>
      <link>http://derickrethans.nl/available-for-php-extension-writing.html</link>
      <description>&lt;div class="article"&gt;
  &lt;div class="body"&gt;
    &lt;div class="articleListItem"&gt;
      &lt;h1&gt;&lt;a name="available_for_php_extension_writing"/&gt;Available for PHP Extension Writing&lt;/h1&gt;
      &lt;dl class="head"/&gt;
      &lt;div class="articleMetaData"&gt;
        &lt;div class="location"&gt; London, UK&lt;/div&gt;
        &lt;div class="date"&gt;Monday, March 15th 2010, 12:28 GMT&lt;/div&gt;
      &lt;/div&gt;
      &lt;p&gt;Slightly more than a month ago I left my job as team-lead of &lt;a href="http://ezcomponents.org"&gt;eZ Components&lt;/a&gt; at &lt;a href="http://ez.no"&gt;eZ Systems&lt;/a&gt; behind, to focus on something new. During the past month I've been contemplating about what to do next and realized that I do not want to take on a new full-time position right away.  Instead I will be available to work on (custom) PHP extensions and internals related issues. Extensions are a great way around PHP's limitations and performance issues.&lt;/p&gt;
      &lt;p&gt;As first project I am working on a "&lt;a href="https://github.com/derickr/quickhash"&gt;QuickHash&lt;/a&gt;" extension for &lt;a href="http://www.stumbleupon.com/"&gt;StumbleUpon&lt;/a&gt;. This extension circumvents PHP's hefty memory (and performance) overhead by providing more specific data structures. The extension currently implements integer sets and integer to integer hashes. I am now adding integer to string hashes and string to integer hashes. The QuickHash extension will be released under the PHP Licence and I will dedicate another post to it later.&lt;/p&gt;
      &lt;p&gt;If, like &lt;a href="http://www.stumbleupon.com/"&gt;StumbleUpon&lt;/a&gt;, you are also interested in having work done on PHP or a specific extensions feel free to &lt;a href="http://derickrethans.nl/who.html"&gt;contact&lt;/a&gt; me. I'd be happy to discuss things with you.&lt;/p&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</description>
      <guid>201003151228</guid>
      <pubDate>Mon, 15 Mar 2010 12:28:00 +0000</pubDate>
    </item>
    <item>
      <title>New Xdebug browser extensions</title>
      <link>http://derickrethans.nl/new-xdebug-helper.html</link>
      <description>&lt;div class="article"&gt;
  &lt;div class="body"&gt;
    &lt;div class="articleListItem"&gt;
      &lt;h1&gt;&lt;a name="new_xdebug_browser_extensions"/&gt;New Xdebug browser extensions&lt;/h1&gt;
      &lt;dl class="head"/&gt;
      &lt;div class="articleMetaData"&gt;
        &lt;div class="location"&gt; London, UK&lt;/div&gt;
        &lt;div class="date"&gt;Wednesday, February 17th 2010, 12:33 GMT&lt;/div&gt;
      &lt;/div&gt;
      &lt;p&gt;Years ago I &lt;a href="http://derickrethans.nl/starting-xdebugs-debugger-with-firefox.html"&gt;wrote&lt;/a&gt; about a Firefox extension that allows you to start an &lt;a href="http://xdebug.org"&gt;Xdebug&lt;/a&gt; debugging session by clicking on an icon in Firefox' status bar. For some unexplained reason, this extension is no longer available through Firefox' addon-site. Although I have a copy at &lt;a href="http://xdebug.org/files/xdebug_helper-0.3.1-fx.xpi"&gt;http://xdebug.org/files/xdebug_helper-0.3.1-fx.xpi&lt;/a&gt; for archival purposes, there are now a few other browser extensions that do the same thing.&lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;easy Xdebug&lt;/strong&gt;
      &lt;/p&gt;
      &lt;p&gt;&lt;a href="https://addons.mozilla.org/en-US/firefox/addon/58688"&gt;easy Xdebug&lt;/a&gt; is an extension that serves as a replacement for the now unavailable Xdebug helper extension. It's written by &lt;a href="https://addons.mozilla.org/en-US/firefox/user/5114063"&gt;Brecht Vanhaesebrouck&lt;/a&gt; of &lt;a href="http://www.elime.be/"&gt;eLime&lt;/a&gt;. The extension was originally tested with &lt;a href="http://netbeans.org/"&gt;Netbeans&lt;/a&gt; but it also seems to work fine with &lt;a href="http://www.activestate.com/komodo/"&gt;Komodo&lt;/a&gt;.&lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;Xdebug enabler&lt;/strong&gt;
      &lt;/p&gt;
      &lt;p&gt;&lt;a href="http://blog.remailed.net/2010/01/xdebug-enabler-v0-2/"&gt;Xdebug enabler&lt;/a&gt; is an extension for Google's Chrome browser. It &lt;em&gt;"allows you to enable and disable triggering Xdebug from with in Chrome. Useful if you are a web developer using an IDE that supports Xdebug like Eclipse with PDT."&lt;/em&gt; It's written by 'remailednet' and available through the &lt;a href="https://chrome.google.com/extensions/detail/eippbhbeglgcphcjmpjcjinjamabeoln"&gt;Google Chrome Extensions&lt;/a&gt; website.&lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;JavaScript 'enabler'&lt;/strong&gt;
      &lt;/p&gt;
      &lt;p&gt;I also ran across a &lt;a href="http://highervisibilitywebsites.com/simple-cross-browser-xdebug-helper-session-starter-and-stopper-no-add-ons-needed"&gt;blog post&lt;/a&gt; by 'Caleb G' from &lt;a href="http://highervisibilitywebsites.com/"&gt;HigherVisibility&lt;/a&gt;. Instead of making an extension for a specific browser, he outlines two JavaScript bookmarklets that allow you to start and stop an &lt;a href="http://xdebug.org"&gt;Xdebug&lt;/a&gt; debugging session.&lt;/p&gt;
      &lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; The "Xdebug enabler" Chrome Extension seems to have some issues. There is now also an alternative Chrome Extension called &lt;strong&gt;Xdebug helper&lt;/strong&gt; that integrates quite a bit better. You can find it at its &lt;a href="https://chrome.google.com/extensions/detail/eadndfjplgieldjbigjakmdgkmoaaaoc"&gt;Google Chrome Extension&lt;/a&gt; page.&lt;/p&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</description>
      <guid>201002171233</guid>
      <pubDate>Wed, 17 Feb 2010 12:33:00 +0000</pubDate>
    </item>
    <item>
      <title>Xdebug moved to a new server</title>
      <link>http://derickrethans.nl/xdebug-moved-to-a-new-server.html</link>
      <description>&lt;div class="article"&gt;
  &lt;div class="body"&gt;
    &lt;div class="articleListItem"&gt;
      &lt;h1&gt;&lt;a name="xdebug_moved_to_a_new_server"/&gt;Xdebug moved to a new server&lt;/h1&gt;
      &lt;dl class="head"/&gt;
      &lt;div class="articleMetaData"&gt;
        &lt;div class="location"&gt; London, UK&lt;/div&gt;
        &lt;div class="date"&gt;Friday, November 27th 2009, 14:42 GMT&lt;/div&gt;
      &lt;/div&gt;
      &lt;p&gt;&lt;a href="http://xdebug.org"&gt;Xdebug&lt;/a&gt; 's CVS server was previously hosted at &lt;a href="http://ez.no"&gt;eZ Systems&lt;/a&gt;' office, but as I am leaving soon I needed to move this to a different server. At the same time, I decided to also convert from CVS to SVN. So from now on, there is no more cvs.xdebug.org, but just a &lt;a href="http://svn.xdebug.org"&gt;svn.xdebug.org&lt;/a&gt;. This SVN server doesn't only host Xdebug, but also some of my other projects, such as &lt;a href="http://svn.xdebug.org/cgi-bin/viewvc.cgi/vld/?root=php"&gt;VLD&lt;/a&gt; (opcode dumper to aid PHP engine development), the &lt;a href="http://svn.xdebug.org/cgi-bin/viewvc.cgi/?root=xdebug"&gt;DBGp&lt;/a&gt; specs (debugger protocol as used by Xdebug and &lt;a href="http://aspn.activestate.com/ASPN/Downloads/Komodo/RemoteDebugging"&gt;ActiveState's debuggers&lt;/a&gt;) and my OpenMoko &lt;a href="http://svn.xdebug.org/cgi-bin/viewvc.cgi/?root=openmoko"&gt;perversions and projects&lt;/a&gt;.&lt;/p&gt;
      &lt;p&gt;Xdebug can now be checked out from SVN with:&lt;/p&gt;
      &lt;pre&gt;svn co svn://svn.xdebug.org/svn/xdebug/xdebug/trunk xdebug

&lt;/pre&gt;
      &lt;p&gt;All other Xdebug services (&lt;a href="http://xdebug.org/support.php#list"&gt;mailinglists&lt;/a&gt;, web, e-mail and the &lt;a href="http://bugs.xdebug.org"&gt;bug system&lt;/a&gt;) moved to the same server as well. Just be aware that DNS servers might still need updating when you try to access the new services.&lt;/p&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</description>
      <guid>200911271442</guid>
      <pubDate>Fri, 27 Nov 2009 14:42:00 +0000</pubDate>
    </item>
    <item>
      <title>Xdebug and tracing memory usage</title>
      <link>http://derickrethans.nl/xdebug-and-tracing-memory-usage.html</link>
      <description>&lt;div class="article"&gt;
  &lt;div class="body"&gt;
    &lt;div class="articleListItem"&gt;
      &lt;h1&gt;&lt;a name="xdebug_and_tracing_memory_usage"/&gt;Xdebug and tracing memory usage&lt;/h1&gt;
      &lt;dl class="head"/&gt;
      &lt;div class="articleMetaData"&gt;
        &lt;div class="location"&gt; London, UK&lt;/div&gt;
        &lt;div class="date"&gt;Friday, November 13th 2009, 11:59 GMT&lt;/div&gt;
      &lt;/div&gt;
      &lt;p&gt;Recently people started to ask me how to use &lt;a href="http://xdebug.org"&gt;Xdebug&lt;/a&gt; to figure out which parts of applications use a lot of memory. Traditionally this was part of Xdebug's &lt;a href="http://xdebug.org/docs/profiler"&gt;profiling&lt;/a&gt; functionality. Unfortunately the cachegrind format didn't fit this so well, and because it returned incorrect data I removed this functionality from the profiler. However, there is other functionality in Xdebug that does provide the correct data: the &lt;a href="http://xdebug.org/docs/execution_trace"&gt;function traces&lt;/a&gt;.&lt;/p&gt;
      &lt;p&gt;Function traces log every include, function call and method call to a file. If the &lt;a href="http://xdebug.org/docs/execution_trace#trace_format"&gt;xdebug.trace_format&lt;/a&gt; setting is set to "1" then the trace file is an easy-to-parse tab separated format. The information that is logged includes the time-index when the function started and ended, and it also contains the amount of memory that was in use when entering the function, as well as when leaving it. With the last two numbers it's rather trivial to write a script to figure out which functions/methods increase the memory usage a lot. Of course, nobody had written a script yet to do anything with this information&lt;/p&gt;
      &lt;p&gt;As part of my preparations for my Xdebug talk at &lt;a href="http://phpconference.com"&gt;IPC&lt;/a&gt; next week, I now have written such a script. The script parses the tab-separated function trace files and aggregates all the information by function name. You can sort the output on a few different keys: time-own, memory-own, time-inclusive, memory-inclusive and calls. You can also configure how many elements it will show. As an example here is some output from a trace of one of the presentation system's PHP scripts:&lt;/p&gt;
      &lt;pre&gt;$ php tracefile-analyser.php trace.2043925204.xt memory-own 20

&lt;/pre&gt;
      &lt;pre&gt;parsing...
Done.
Showing the 20 most costly calls sorted by 'memory-own'.
                                               Inclusive        Own
function                               #calls  time     memory  time     memory
-------------------------------------------------------------------------------
require_once                                9  0.0541  4595160  0.0277  2548104
{main}                                      1  0.0600  2906032  0.0034   249744
fread                                       4  0.0001    33296  0.0001    33296
session_start                               1  0.0002    31824  0.0002    31824
XML_Presentation-&gt;startHandler             38  0.0073    36360  0.0035    18424
_pres_slide-&gt;_pres_slide                   27  0.0009    10152  0.0009    10152
_presentation-&gt;_presentation                1  0.0001     7912  0.0001     7912
strtolower                                 67  0.0017     6456  0.0017     6456
compact                                     1  0.0000     4832  0.0000     4832
each                                        5  0.0001     4320  0.0001     4320
XML_Presentation-&gt;endHandler               38  0.0014     3800  0.0014     3960
_slide-&gt;_slide                              1  0.0001     3896  0.0001     3896
XML_Slide-&gt;startHandler                     4  0.0009    10800  0.0004     3736
_image-&gt;_image                              1  0.0000     3040  0.0000     3040
fopen                                       2  0.0001     2816  0.0001     2816
getimagesize                                1  0.0001     2296  0.0001     2296
display-&gt;display                            1  0.0001     2120  0.0001     2120
explode                                     2  0.0001     2120  0.0001     2120
xml_parser_create                           2  0.0001     1680  0.0001     1680
XML_Parser-&gt;_initHandlers                   2  0.0011     1600  0.0005     1360

&lt;/pre&gt;
      &lt;p&gt;The script is available from SVN by running:&lt;/p&gt;
      &lt;pre&gt;svn co svn://svn.xdebug.org:/svn/xdebug/xdebug/trunk/contrib xdebug/contrib

&lt;/pre&gt;
      &lt;p&gt;The script to run is then "tracefile-analyser.php" from inside the "xdebug/contrib" directory.&lt;/p&gt;
      &lt;p&gt;&lt;strong&gt;Update 2009-12-28&lt;/strong&gt;: Changed the CVS instructions to the new SVN instructions.&lt;/p&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</description>
      <guid>200911131159</guid>
      <pubDate>Fri, 13 Nov 2009 11:59:00 +0000</pubDate>
    </item>
    <item>
      <title>Good bye eZ Systems</title>
      <link>http://derickrethans.nl/good-bye-ez-systems.html</link>
      <description>&lt;div class="article"&gt;
  &lt;div class="body"&gt;
    &lt;div class="articleListItem"&gt;
      &lt;h1&gt;&lt;a name="good_bye_ez_systems"/&gt;Good bye eZ Systems&lt;/h1&gt;
      &lt;dl class="head"/&gt;
      &lt;div class="articleMetaData"&gt;
        &lt;div class="location"&gt; London, UK&lt;/div&gt;
        &lt;div class="date"&gt;Tuesday, October 27th 2009, 10:36 GMT&lt;/div&gt;
      &lt;/div&gt;
      &lt;p&gt;During the past 6 years I've been working as a developer for &lt;a href="http://ez.no"&gt;eZ Systems&lt;/a&gt; — first as a developer on eZ Publish and later as project lead for &lt;a href="http://ezcomponents.org"&gt;eZ Components&lt;/a&gt;. Working on a project like &lt;a href="http://ezcomponents.org"&gt;eZ Components&lt;/a&gt; as lead was challenging and interesting and taught me many things. &lt;a href="http://ez.no"&gt;eZ Systems&lt;/a&gt; as a company is changing a lot, and now the time has come for me to move on and find something new and exciting to do. I've recently &lt;a href="http://derickrethans.nl/good_bye_norway_hello_london.php"&gt;moved to London&lt;/a&gt; to explore life from a different point of view, and that will now also include a search for a new challenge professionally. I will still be with eZ Systems for awhile longer to finish the next &lt;a href="http://ezcomponents.org"&gt;eZ Components&lt;/a&gt; release. If you think you can provide me with a new challenge, feel free to contact &lt;a href="http://derickrethans.nl/who.php"&gt;me&lt;/a&gt;.&lt;/p&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</description>
      <guid>200910271036</guid>
      <pubDate>Tue, 27 Oct 2009 10:36:00 +0000</pubDate>
    </item>
    <item>
      <title>Debugging with multiple users</title>
      <link>http://derickrethans.nl/debugging-with-multiple-users.html</link>
      <description>&lt;div class="article"&gt;
  &lt;div class="body"&gt;
    &lt;div class="articleListItem"&gt;
      &lt;h1&gt;&lt;a name="debugging_with_multiple_users"/&gt;Debugging with multiple users&lt;/h1&gt;
      &lt;dl class="head"/&gt;
      &lt;div class="articleMetaData"&gt;
        &lt;div class="location"&gt; Amsterdam, the Netherlands&lt;/div&gt;
        &lt;div class="date"&gt;Thursday, June 11th 2009, 10:47 CEST&lt;/div&gt;
      &lt;/div&gt;
      &lt;p&gt;As author of &lt;a href="http://xdebug.org"&gt;Xdebug&lt;/a&gt;, people ask me often the question how to handle the case in teams when there is one development server and multiple developers working on the same project on that server. Xdebug only allows you to specify &lt;em&gt;one&lt;/em&gt; IP address to connect to (through &lt;a href="http://xdebug.org/docs/remote#remote_host"&gt;xdebug.remote_host&lt;/a&gt; ) while doing &lt;a href="http://xdebug/docs/remote"&gt;remote debugging&lt;/a&gt;. It does not automatically connect back to the IP address that runs the browser the request the PHP scripts because of security reasons. You don't want everybody on the Internet to be able to run a debugging session against your code for example. There is no problem if all developers are working on a different project, because the xdebug.remote_host setting can be made for each directory (through Apache's .htaccess functionality). However, for the case where multiple developers work on the same code, the .htaccess trick won't work as the directory in which the code lives is the same.&lt;/p&gt;
      &lt;img src="http://derickrethans.nl/images/content/xdebug_logo.png" class="left" alt="xdebug_logo.png"/&gt;
      &lt;p&gt;Now, in order to solve the above mentioned issue, you will need to run a DBGp proxy. DBGp is the protocol, designed by &lt;a href="http://activestate.com"&gt;ActiveState&lt;/a&gt; and myself to facilitate communication between an IDE (such as &lt;a href="http://activestate.com/komodo"&gt;Komodo&lt;/a&gt;, or any of the other &lt;a href="http://xdebug.org/docs/remote#clients"&gt;listed clients&lt;/a&gt; ) and PHP+Xdebug. A DBGp proxy is a bit of software that acts as a redirector for DBGp streams. In order to make things work for multiple developers and one source base, you set Xdebug's xdebug.remote_host setting to the machine on which the DBGp proxy runs. This is most likely going to be on the same machine that acts as development server, so that the xdebug.remote_host setting should be set to "127.0.0.1" (i.e. localhost). The proxy server the listens for IDE connections. An IDE needs to register itself with the DBGp proxy by using the &lt;a href="http://xdebug.org/docs-dbgp.php#just-in-time-debugging-and-debugger-proxies"&gt;proxyinit command&lt;/a&gt;. This command requires an "idekey" that is a unique identifier for each client (IDE). Every developer should have its own unique idekey (I usually just pick my name), and this idekey should be configurable in the IDE. For Komodo, it's at Edit-&gt;Preferences-&gt;Debugger-&gt;Connection-&gt;"I am running a debugger proxy and Komodo should use it"-&gt;"Proxy Key". In Komodo you also need to select "a system-provided free port" in the same configuration panel. When initiating the debugging session from the browser with either XDEBUG_SESSION_START=session_name as GET/POST/COOKIE parameter, or export XDEBUG_CONFIG="idekey=session_name" from the comment line, make sure to change "session_name" to the idekey as configured in your IDE. (See &lt;a href="http://xdebug.org/docs/remote#starting"&gt;the documentation&lt;/a&gt; on how to set this up). The Xdebug &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/3960"&gt;Firefox extension&lt;/a&gt; also has a setting for this. You have to configure Xdebug's &lt;a href="http://xdebug.org/docs/remote#remote_host"&gt;xdebug.remote_host&lt;/a&gt; setting to the IP address of the machine that the proxy runs at. Xdebug itself does not see a difference between either the proxy and a normal IDE. But the proxy itself now knows because of the configured idekey on how to forward the requests and responses to the correct client.&lt;/p&gt;
      &lt;p&gt;You can find the DBGp proxy code as part of the &lt;strong&gt;python&lt;/strong&gt; remote debugging package that ActiveState &lt;a href="http://aspn.activestate.com/ASPN/Downloads/Komodo/RemoteDebugging"&gt;provides&lt;/a&gt;. By default it listens for IDE registrations at port 9001, and for Xdebug connections at port 9000. To run the proxy, do:&lt;/p&gt;
      &lt;pre&gt;tar -xvzf Komodo-PythonRemoteDebugging-5.1.3-28369-linux-x86_64.tar.gz
cd Komodo-PythonRemoteDebugging-5.1.3-28369-linux-x86_64
cd bin
./pydbgpproxy

&lt;/pre&gt;
      &lt;p&gt;This outputs:&lt;/p&gt;
      &lt;pre&gt;INFO: dbgp.proxy: starting proxy listeners.  appid: 30430
INFO: dbgp.proxy:     dbgp listener on 127.0.0.1:9000
INFO: dbgp.proxy:     IDE listener on  127.0.0.1:9001

&lt;/pre&gt;
      &lt;p&gt;Running a DBGp proxy also allows you to avoid NAT issues where (as seen from PHP+Xdebug on the server) all connections seem to come from the same IP (because your internal network is NATted). In this case, you can simple run the dbgp proxy on your NAT machine, configure xdebug.remote_host setting to the IP address of your NAT machine, and configure the IDEs to connect to the proxy running at &lt;NAT-machine&gt;:9001.&lt;/p&gt;
      &lt;p&gt;As a last note; there is a patch to allow the connect-back-to-requesting-IP-address functionality that is not available directly in Xdebug. This patch, written by Brian Shire and Lucas Nealan of &lt;a href="http://facebook.com"&gt;Facebook&lt;/a&gt; made its way into Xdebug 2.1. However, great care should be taken by using this functionality. It does not make the NAT situation as outlined above work however.&lt;/p&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</description>
      <guid>200906111047</guid>
      <pubDate>Thu, 11 Jun 2009 08:47:00 +0000</pubDate>
    </item>
    <item>
      <title>PHP's two-pass compiler</title>
      <link>http://derickrethans.nl/phps-twopass-compiler.html</link>
      <description>&lt;div class="article"&gt;
  &lt;div class="body"&gt;
    &lt;div class="articleListItem"&gt;
      &lt;h1&gt;&lt;a name="php_s_two-pass_compiler"/&gt;PHP's two-pass compiler&lt;/h1&gt;
      &lt;dl class="head"/&gt;
      &lt;div class="articleMetaData"&gt;
        &lt;div class="location"&gt; Istanbul, Turkey&lt;/div&gt;
        &lt;div class="date"&gt;Saturday, January 24th 2009, 20:55 EET&lt;/div&gt;
      &lt;/div&gt;
      &lt;p&gt;On my way to Istanbul I was looking at Xdebug bug &lt;a href="http://bugs.xdebug.org/view.php?id=422"&gt;#422&lt;/a&gt; . For some reason Xdebug was crashing while doing code-coverage analysis, in the part that analyses which code was dead (ie. opcodes that could never be reached). The crash occurred with a JMPZ (jump-if-zero) instruction, that suddenly saw a jump-to position of 572222864. That position resembles more a jump-address.&lt;/p&gt;
      &lt;p&gt;Xdebug uses the same branch analysis implementation as &lt;a href="http://derickrethans.nl/vld.php"&gt;VLD&lt;/a&gt; so I used the latter tool to find out why it would crash. Unfortunately, it was working just all nice and fine with VLD. After digging around some more, I saw from the back trace that the crash in &lt;a href="http://xdebug.org"&gt;Xdebug&lt;/a&gt; only occurred when a user-defined error-handler was called while parsing a file. The latter gave me the insight of looking at which phase the compiler was in. I remembered that PHP has a two phase compiler. The first pass is quick and dirty, and only records the opcode line &lt;em&gt;number&lt;/em&gt; to jump to. Xdebug however was expecting an &lt;em&gt;memory address&lt;/em&gt; as jump target. Because a memory address is a much larger number than an opcode number—the latter usually not being much higher than a thousand—Xdebug was setting the "visited" flag in a part of memory that wasn't allocated. And writing to unallocated memory makes a process die with a segmentation fault.&lt;/p&gt;
      &lt;p&gt;The compiler in PHP is two-pass. During the first pass, it will find out to which opcode it needs to jump in the jump instructions. However, the PHP engine (and Xdebug) expects a memory address to jump to while &lt;em&gt;executing&lt;/em&gt; your script. In the second pass, the compiler will then go over the generated opcodes and calculate the memory address to jump to from the jumps to opcode numbers. It will also do a few other things, such as collapsing sequential EXT_STMT opcodes, calling Zend extension's functions to finalize the opcode arrays—Xdebug uses this for caching whether an opcode array has been scanned already—and re-allocating the opcode array itself to save space.&lt;/p&gt;
      &lt;p&gt;Now, the thing is, that usually VLD and Xdebug kick in &lt;em&gt;after&lt;/em&gt; the whole opcode array has been created, which includes running the second pass of the compiler. However, Xdebug also tries to analyze opcode arrays while executing them. In the case of a user defined error handler, that happens before the second pass has been run. Preventing the crash was therefore as easy as making sure that the compiler's second pass had been run while scanning the opcode arrays for executable code.&lt;/p&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</description>
      <guid>200901242055</guid>
      <pubDate>Sat, 24 Jan 2009 18:55:00 +0000</pubDate>
    </item>
    <item>
      <title>Conferences in Winter/Spring 2009</title>
      <link>http://derickrethans.nl/conferences-in-winterspring-2009.html</link>
      <description>&lt;div class="article"&gt;
  &lt;div class="body"&gt;
    &lt;div class="articleListItem"&gt;
      &lt;h1&gt;&lt;a name="conferences_in_winter_spring_2009"/&gt;Conferences in Winter/Spring 2009&lt;/h1&gt;
      &lt;dl class="head"/&gt;
      &lt;div class="articleMetaData"&gt;
        &lt;div class="location"&gt; Skien, Norway&lt;/div&gt;
        &lt;div class="date"&gt;Tuesday, January 13th 2009, 10:47 CET&lt;/div&gt;
      &lt;/div&gt;
      &lt;p&gt;In the next five months I've lined up quite a few conferences. First of all, there is &lt;a href="http://www.webprogramcilariplatformu.org/?"&gt;Web Programcıları Platformu&lt;/a&gt; in Istanbul, where I will be giving the closing keynote to inspire Turkish talent on January 24th.&lt;/p&gt;
      &lt;img src="http://derickrethans.nl/images/content/phpquebec-logo.gif" class="left" alt="phpquebec-logo.gif"/&gt;
      &lt;p&gt;The week after that I'll be traveling to Barcelona for the &lt;a href="http://ez.no/company/events/ez_international_winter_conferences"&gt;eZ International Winter Conference&lt;/a&gt; to give a tutorial to the new &lt;a href="http://ezcomponents.org/s/MvcTools"&gt;MvcTools&lt;/a&gt; component.&lt;/p&gt;
      &lt;p&gt;In March I will speak at &lt;a href="http://conf.phpquebec.org/"&gt;PHP Quebec Conference&lt;/a&gt; on &lt;a href="http://tek.mtacon.com/c/schedule/talk/d1s3/1"&gt;searching with PHP&lt;/a&gt; , &lt;a href="http://tek.mtacon.com/c/schedule/talk/d2s2/2"&gt;simple application design&lt;/a&gt; and &lt;a href="http://ezcomponents.org"&gt;eZ Components&lt;/a&gt; .&lt;/p&gt;
      &lt;img src="http://derickrethans.nl/images/content/img-tek_09_badge_speaker-71470.gif" class="right" alt="img-tek_09_badge_speaker-71470.gif"/&gt;
      &lt;p&gt;In April I will travel to Veliko Tŭrnovo in Bulgaria to speak at the WebTech conference on PHP-on-DBUS and Test Driven Development.&lt;/p&gt;
      &lt;p&gt;The line-up ends with a trip to Chicago to give a talk on &lt;a href="http://tek.mtacon.com/c/schedule/talk/d1s3/1"&gt;searching with PHP&lt;/a&gt; , &lt;a href="http://tek.mtacon.com/c/schedule/talk/d2s2/2"&gt;simple application design&lt;/a&gt; .&lt;/p&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</description>
      <guid>200901131047</guid>
      <pubDate>Tue, 13 Jan 2009 09:47:00 +0000</pubDate>
    </item>
    <item>
      <title>Leap Seconds and What To Do With Them</title>
      <link>http://derickrethans.nl/leap-seconds-and-what-to-do-with-them.html</link>
      <description>&lt;div class="article"&gt;
  &lt;div class="body"&gt;
    &lt;div class="articleListItem"&gt;
      &lt;h1&gt;&lt;a name="leap_seconds_and_what_to_do_with_them"/&gt;Leap Seconds and What To Do With Them&lt;/h1&gt;
      &lt;dl class="head"/&gt;
      &lt;div class="articleMetaData"&gt;
        &lt;div class="location"&gt; Skien, Norway&lt;/div&gt;
        &lt;div class="date"&gt;Thursday, January 1st 2009, 23:03 CET&lt;/div&gt;
      &lt;/div&gt;
      &lt;img src="http://derickrethans.nl/images/content/clock.jpg" class="right" alt="clock.jpg"/&gt;
      &lt;p&gt;The start of this new year started with some buzz about a &lt;a href="http://en.wikipedia.org/wiki/Leap_second"&gt;leap second&lt;/a&gt; being introduced between Dec 31st 2008, 23:59:59 and Jan 1st 2009, 00:00:00. I've had people ask where this leap second actually comes from, and whether you need to worry about it in your applications. To understand leap seconds means, unfortunately, understanding how time is actually kept.&lt;/p&gt;
      &lt;p&gt;There are many different time keeping scales. They are either defined as an arbitrary value, or obtained from astronomical observations. First of all, there are the variants of &lt;a href="http://en.wikipedia.org/wiki/Universal_Time#Versions"&gt;Universal Time&lt;/a&gt;. UT1 is the principal form of Universal Time. UT1 is the same all over the world, and is related to the Earths rotation. The rotation speed of the Earth is not precise, and is slowed down by the tidal friction of the Moon among things. Obviously, this is a bad base to build a stable and precise timekeeping scale on.&lt;/p&gt;
      &lt;p&gt;An (SI) second is nowadays defined as "the duration of 9 192 631 770 periods of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the caesium 133 atom". This can be measured very accurately by atomic clocks and is the base for &lt;a href="http://en.wikipedia.org/wiki/International_Atomic_Time"&gt;International Atomic Time&lt;/a&gt; (TAI, from Temps Atomique International). This scale however, does not take into account the gradual but increasing slowing down of the Earth's rotation and will therefore not reflect the approximation to "mean solar time" over longer periods of time. This makes it useless as a civil timekeeping scale.&lt;/p&gt;
      &lt;p&gt;For the latter purpose, &lt;a href="http://en.wikipedia.org/wiki/Coordinated_Universal_Time"&gt;Coordinated Universal Time&lt;/a&gt; (UTC, from Universal Time, Coordinated) has been established. UTC uses SI seconds but is adjusted for the slowing down of Earths rotation with leap seconds. Because it's not possible to predict the rotation of the Earth upfront, leap seconds are only added when the difference between UTC and UT1 approaches 0.6 SI seconds in order to keep UTC and UT1 not differ from each other for more than 0.9 seconds. UTC was defined (in the latest adjustment of its definition) as being 10 seconds different from TAI making 1972-01-01T00:00:00 UTC and 1972-01-01T00:00:10 TAI the same instant. Since 1972, 24 leap seconds have been introduced, making TAI differ from UTC with 34 seconds currently. As the Earth's rotation is slowing down at an ever increasing rate, the use of leap seconds will get more and more annoying. After the 25th century, it is likely that more than 4 leap seconds would be required every year. This is of course highly unpractical and a solution needs to be found for this.&lt;/p&gt;
      &lt;p&gt;There are two other timescales based on TAI. &lt;a href="http://en.wikipedia.org/wiki/Terrestrial_Time"&gt;Terrestial Time&lt;/a&gt; (TT) as the modern astronomical standard for the passage of time. TT is defined as TAI + 32.184 seconds. &lt;a href="http://en.wikipedia.org/wiki/Global_Positioning_System#Timekeeping"&gt;GPS Time&lt;/a&gt;, as used by GPS satellites and receivers, was set to match UTC in 1980, but now deviates with 15 seconds due to the addition of leap seconds in UTC. GPS Time is defined as TAI - 19 seconds.&lt;/p&gt;
      &lt;p&gt;Greenwich Mean Time (GMT) is often used as synonym for UTC, although that is strictly not correct. GMT is an astronomical concept and therefore linked to UT1. Greenwich Mean Time is &lt;em&gt;also&lt;/em&gt; used as timezone name for a timezone with zero seconds offset from UTC. It is for example used in winter in the UK and Ireland. During the summer, when the UK and Ireland switch to daylight savings time, GMT is not used at all. British Summer Time (BST) and Ireland Summer Time (IST) are then used instead.&lt;/p&gt;
      &lt;p&gt;A thing to realize is that leap seconds are added only at the end of June 30th and December 31st. The seconds are added at 23:59:59 &lt;em&gt;UTC&lt;/em&gt; . This means that there is no need to add an extra second while counting down to the new year unless you're in a timezone that is UTC +0 seconds (such as GMT, or WET). Of course, in other locations the leap second is inserted as well at the same time. In Norway, the leap second was added at Jan 1st, 2009, at 00:59:59 for example.&lt;/p&gt;
      &lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Unix_time"&gt;Unix time&lt;/a&gt; (also called POSIX time) is defined as the number of seconds since Jan 1st 1970, 00:00 UTC, but without leap seconds. Although it is called &lt;em&gt;Unix time&lt;/em&gt; , this timekeeping standard is used widely in many other operating systems and computing devices. Unix time simply counts the number of seconds since the epoch. A date/time expressed in those seconds is often called a Unix time stamp. Not supporting leap seconds means that Unix time does not have any way to represent the leap second in the form of 23:59:60. Instead it just uses the same second twice. In practical terms, that means that Unix time progressed like this during the year transition: 1230767999, 1230768000, 1230768000 and 1230768001. The first 1230768000 represents 2008-12-31 23:59:60 UTC, and the second 1230768000 represents 2009-01-01 00:00:00 UTC. For applications there is no way to differentiate between the two distinct times, although many applications will accept both as input, like this PHP example shows:&lt;/p&gt;
      &lt;pre&gt;&lt;?php
echo strtotime("2008-12-31 23:59:59 UTC"), "\n";
echo strtotime("2008-12-31 23:59:60 UTC"), "\n";
echo strtotime("2009-01-01 00:00:00 UTC"), "\n";
echo strtotime("2009-01-01 00:00:01 UTC"), "\n";
?&gt;

&lt;/pre&gt;
      &lt;p&gt;In order to synchronize the system time the &lt;a href="http://en.wikipedia.org/wiki/Network_Time_Protocol"&gt;Network Time Protocol&lt;/a&gt; (NTP) is widely used. NTP can use different sources of time information in an hierarchical fashion. The protocol knows how to deal with leap seconds to provide the correct Unix time stamp.&lt;/p&gt;
      &lt;p&gt;To recap the above information: UT1 is based on the actual rotational speed of the Earth and is therefore never accurate. TAI is a time scale based on the actual count of SI seconds. UTC also uses SI seconds, but requires a leap second in order not to deviate from the unstable UT1 which is in sync with the average time of when the Sun is due South (mean solar time). Unix time counts SI seconds, and resembles UTC except that instead of leap seconds, the Unix time stamp is simply used twice. GMT is both a different name for UT1 &lt;em&gt;and&lt;/em&gt; a name for a timezone with an UTC offset of 0 seconds. PHP uses Unix time, and does not care about leap seconds.&lt;/p&gt;
      &lt;p&gt;Happy New Year!&lt;/p&gt;
      
      
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</description>
      <guid>200901012303</guid>
      <pubDate>Thu, 01 Jan 2009 22:03:00 +0000</pubDate>
    </item>
    <item>
      <title>Xdebug 2.0.4</title>
      <link>http://derickrethans.nl/xdebug-204.html</link>
      <description>&lt;div class="article"&gt;
  &lt;div class="body"&gt;
    &lt;div class="articleListItem"&gt;
      &lt;h1&gt;&lt;a name="xdebug_2_0_4"/&gt;Xdebug 2.0.4&lt;/h1&gt;
      &lt;dl class="head"/&gt;
      &lt;div class="articleMetaData"&gt;
        &lt;div class="location"&gt; Dieren, the Netherlands&lt;/div&gt;
        &lt;div class="date"&gt;Tuesday, December 30th 2008, 16:46 CET&lt;/div&gt;
      &lt;/div&gt;
      &lt;img src="http://derickrethans.nl/images/content/xdebug_logo.png" class="left" alt="xdebug_logo.png"/&gt;
      &lt;p&gt;I just released &lt;a href="http://xdebug.org/updates.php#x_2_0_4"&gt;Xdebug 2.0.4&lt;/a&gt; which addresses bugs from the Xdebug 2.0 branch, including bug fixes related to crashes on Vista. You can get Xdebug through PECL (pecl install xdebug) or from the &lt;a href="http://xdebug.org"&gt;Xdebug&lt;/a&gt; site. Windows binaries will be made available later.&lt;/p&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</description>
      <guid>200812301646</guid>
      <pubDate>Tue, 30 Dec 2008 15:46:00 +0000</pubDate>
    </item>
  </channel>
</rss>

