<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Planet PHP</title><link rel="alternate" type="text/html" href="http://www.planet-php.net/"/><link rel="self" type="text/html" href="http://www.planet-php.net/atom/"/><subtitle>People blogging about PHP</subtitle><id>http://www.planet-php.net/</id><generator uri="http://planet-php.net/">
            Planet PHP Aggregator
            </generator><updated>2013-06-18T16:26:00Z</updated><link rel="hub" href="http://pubsubhubbub.appspot.com"/><entry><title type="text">Hear, hear</title><link rel="alternate" type="text/html" href="http://m6w6.blogspot.com/2013/06/hear-hear.html" title="Hear, hear"/><link rel="shortlink" type="text/html" href="http://planet-php.org/~ppl" title="Shortlink to http://m6w6.blogspot.com/2013/06/hear-hear.html"/><author><name>Mike's sudden inspirations</name></author><id>tag:blogger.com,1999:blog-3548191306209306753.post-1376560546594423862</id><updated>2013-06-18T16:26:00Z</updated><published>2013-06-18T16:26:00Z</published><content type="html"><![CDATA[I was about to write "in early February" but actually it already was in late January that I stumbled over this tweet:<br /><blockquote class="twitter-tweet">I'm still ready & willing to hire a <a href="https://twitter.com/search?q=%23PHP&src=hash">#PHP</a> internals coder to work on PHP fulltime. Amazing place to work: <a href="http://t.co/GX4wtPSc">http://t.co/GX4wtPSc</a><br />— Don MacAskill (@DonMacAskill) <a href="https://twitter.com/DonMacAskill/statuses/292117608076021760">January 18, 2013</a></blockquote>&lt;script async="" charset="utf-8" src="//platform.twitter.com/widgets.js"></script> <br />Fast-forward five months – now I am very excited to be able to announce that the Awesomes over at <a href="http://www.smugmug.com/">SmugMug, Inc</a>. have hired me to work full-time on the core of PHP.<br /><br />Hide <a href="http://bugs.php.net/">bugs.php.net</a>, expect massive amounts of commits, sleep well. Thank you for reading the simple words of the proudest man alive. Thank you SmugMug!<br /><br />]]></content></entry><entry><title type="text">Packing a Symfony full-stack Framework Application in one File -- Bootstrapping</title><link rel="alternate" type="text/html" href="http://feeds.fabien.potencier.org/~r/aidedecamp/~3/U3V3yT2-9wk/packing-a-symfony-full-stack-framework-application-in-one-file-bootstrapping" title="Packing a Symfony full-stack Framework Application in one File -- Bootstrapping"/><link rel="shortlink" type="text/html" href="http://planet-php.org/~po7" title="Shortlink to http://feeds.fabien.potencier.org/~r/aidedecamp/~3/U3V3yT2-9wk/packing-a-symfony-full-stack-framework-application-in-one-file-bootstrapping"/><author><name>Fabien Potencier</name></author><id>http://fabien.potencier.org/article/70/packing-a-symfony-full-stack-framework-application-in-one-file-bootstrapping</id><updated>2013-06-18T08:30:00Z</updated><published>2013-06-18T08:30:00Z</published><content type="html"><![CDATA[
    <blockquote class="note"><p>
  This article is part of a series of articles that explains how to pack a Symfony
  full-stack application in one file. The first article explains why this might actually
  be useful:
  1) <a href="http://fabien.potencier.org/article/69/packing-a-symfony-full-stack-framework-application-in-one-file-introduction">Introduction</a>,
  2) <a href="http://fabien.potencier.org/article/70/packing-a-symfony-full-stack-framework-application-in-one-file-bootstrapping">Bootstrapping</a>,
  ...</p>
</blockquote>

<p>The most common way to create a Symfony project is to start with the Symfony
<a href="http://symfony.com/download">Standard Edition</a>: it defines a sensible
directory structure for your project and it make things a lot easier when
someone want to take over an existing project as he knows where the templates,
the controllers, or the configuration are stored. So, let's start our journey
with the Symfony Standard Edition:</p>

<pre class="command-line"><code>$ composer.phar create-project -n symfony/framework-standard-edition se/ 2.3.0
</code></pre>

<p>From there, let's remove a bunch of code to get the bare minimum of code
needed to keep it working:</p>

<pre class="php">rm -rf LICENSE README.md UPGRADE* bin/ app/SymfonyRequirements.php \
       app/autoload.php app/bootstrap.php.cache app/AppCache.php app/check.php \
       app/console app/phpunit.xml.dist app/Resources src/ web/config.php \
       web/favicon.ico web/robots.txt web/apple-touch-icon.png web/app.php web/bundles/ \
       app/cache<span class="coMULTI">/* app/log/* .travis.yml app/.htaccess web/.htaccess
 
</span></pre>

<p>I've removed all those files and directories because there are not needed for
the purpose of our challenge.</p>

<p>Next, let's simplify the configuration and move everything into just one file:</p>

<pre class="php"><span class="co2"># app/config/config_dev.yml</span>
framework:
    secret:          <span class="re0">$ecret</span>
    router:
        resource: <span class="st0">"%kernel.root_dir%/config/routing_dev.yml"</span>
    form:            ~
    csrf_protection: ~
    validation:      <span class="br0">{</span> enable_annotations: <span class="kw2">true</span> <span class="br0">}</span>
    templating:
        engines: <span class="br0">[</span><span class="st0">'twig'</span><span class="br0">]</span>
    session:         ~
    fragments:       ~
 </pre>

<p>The <code>routing_dev.yml</code> file has been emptied for now, and all other
configuration files have been removed.</p>

<p>We can also remove most of the bundles from the application kernel class:</p>

<pre class="php">use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
 
<span class="kw2">class</span> AppKernel <span class="kw2">extends</span> Kernel
<span class="br0">{</span>
    <span class="kw2">public</span> <span class="kw2">function</span> registerBundles<span class="br0">(</span><span class="br0">)</span>
    <span class="br0">{</span>
        <span class="kw1">return</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">(</span>
            <span class="kw2">new</span> Symfony\Bundle\FrameworkBundle\FrameworkBundle<span class="br0">(</span><span class="br0">)</span>,
            <span class="kw2">new</span> Symfony\Bundle\TwigBundle\TwigBundle<span class="br0">(</span><span class="br0">)</span>,
        <span class="br0">)</span>;
    <span class="br0">}</span>
 
    <span class="kw2">public</span> <span class="kw2">function</span> registerContainerConfiguration<span class="br0">(</span>LoaderInterface <span class="re0">$loader</span><span class="br0">)</span>
    <span class="br0">{</span>
        <span class="re0">$loader</span>-><span class="me1">load</span><span class="br0">(</span>__DIR__.<span class="st0">'/config/config_'</span>.<span class="re0">$this</span>-><span class="me1">getEnvironment</span><span class="br0">(</span><span class="br0">)</span>.<span class="st0">'.yml'</span><span class="br0">)</span>;
    <span class="br0">}</span>
<span class="br0">}</span>
 </pre>

<p>We can also simplify the <code>web/app_dev.php</code> code:</p>

<pre class="php">use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;
 
<span class="kw1">require_once</span> __DIR__.<span class="st0">'/../vendor/autoload.php'</span>;
Debug::<span class="me2">enable</span><span class="br0">(</span><span class="br0">)</span>;
 
<span class="kw1">require_once</span> __DIR__.<span class="st0">'/../app/AppKernel.php'</span>;
 
<span class="re0">$kernel</span> = <span class="kw2">new</span> AppKernel<span class="br0">(</span><span class="st0">'dev'</span>, <span class="kw2">true</span><span class="br0">)</span>;
<span class="re0">$request</span> = Request::</pre><p><i>Truncated by Planet PHP, read more at <a href="http://feeds.fabien.potencier.org/~r/aidedecamp/~3/U3V3yT2-9wk/packing-a-symfony-full-stack-framework-application-in-one-file-bootstrapping">the original</a> (another 2876 bytes)</i></p>]]></content></entry><entry><title type="text">Small catch up</title><link rel="alternate" type="text/html" href="http://michaelkimsal.com/blog/small-catch-u/" title="Small catch up"/><link rel="shortlink" type="text/html" href="http://planet-php.org/~poJ" title="Shortlink to http://michaelkimsal.com/blog/small-catch-u/"/><author><name>Michael Kimsal</name></author><id>http://michaelkimsal.com/blog/?p=1129</id><updated>2013-06-17T21:17:00Z</updated><published>2013-06-17T21:17:00Z</published><content type="html"><![CDATA[<p>So… I didn’t write much since April.  I took a bit of time off and went to Russia (<a href="https://plus.google.com/photos/107376902684111594494/albums/5868900241726803921" target="_blank">some</a> <a href="https://plus.google.com/photos/107376902684111594494/albums/5870481216211076945?authkey=CKfxjZHatsfdTA" target="_blank">pics</a> <a href="https://plus.google.com/photos/107376902684111594494/albums/5873302934224888561?authkey=CKzY1PvMqpquwwE" target="_blank">here</a> - more to come later), and have been finishing up some contracts in May/June, and am now looking for the next thing to sink my teeth in to, so to speak (ping me if you’ve got an interesting project you think I might be a fit for).</p>
<p>We’ve got an interesting talk on PHP’s Composer project slated for our next <a href="http://trianglephp.com" target="_blank">PHP user group</a> in Raleigh with our very own <a href="http://www.jasongrimes.org/tag/php/" target="_blank">Jason Grimes</a> - definitely looking forward to this one (come on out if you’re anywhere near the area!)  If you don’t follow Jason already, get to it – he’s got a lot of useful stuff on his blog.</p>
<p>The indieconf <a href="http://indieconf.com" target="_blank">conference for web freelancers</a> is coming again this year – still nailing down a date – but the call for presenters is open right now – <a href="https://docs.google.com/spreadsheet/viewform?formkey=dDctYnlGcXM5Z3VqbzQ1VFJ5eUNFNmc6MA#gid=0" target="_blank">submit your proposal</a> to present if you’re interested in joining us this year!</p>
<p>It’s hard to believe 2013 is almost half over already!!!</p>
<hr/>
<p style="margin-top: 1em; font-style: italic">
I'm currently working on a book for web freelancers, covering everything you need to know to get started or just get better.  Want to stay updated?  Sign up for my mailing list to get updates when the book is ready to be released!
</p>
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup2">
	<form action="http://webdevpub.us1.list-manage.com/subscribe/post?u=48b3cb53de2223846f74aee5e&id=6bd094f6d5" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>

	<div style="float:left; width:150px;">
		<img border="0" style="border: none;" src="http://michaelkimsal.com/web-developer-freelance-handbook/cover07.png" width="130" alt="Web Developer Freelancing Handbook"/>
	</div>

	<div style="float:left;">
		<br/>
		<label for="mce-EMAIL">Get notified when the book is available!</label>
		<input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" required>
	<input type='hidden' name='FROM' value='blogpostbottom' id='mce-FROM'/>
		<div class=""><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"
	</div>
	<div style="clear:both;"></div>
	</form>
</div>
<!--End mc_embed_signup-->
]]></content></entry><entry><title type="text">PHP 5.5 Release Date Imminent - Lately in PHP podcast episode 36</title><link rel="alternate" type="text/html" href="http://www.phpclasses.org/blog/post/209-PHP-55-Release-Date-Imminent--Lately-in-PHP-podcast-episode-36.html" title="PHP 5.5 Release Date Imminent - Lately in PHP podcast episode 36"/><link rel="shortlink" type="text/html" href="http://planet-php.org/~pol" title="Shortlink to http://www.phpclasses.org/blog/post/209-PHP-55-Release-Date-Imminent--Lately-in-PHP-podcast-episode-36.html"/><author><name>PHP Classes</name></author><id>http://www.phpclasses.org/blog/post/209-PHP-55-Release-Date-Imminent--Lately-in-PHP-podcast-episode-36.html</id><updated>2013-06-17T09:42:00Z</updated><published>2013-06-17T09:42:00Z</published><content type="html"><![CDATA[<div style="clear: both">
<div style="margin-top: 1ex"><a href="http://www.phpclasses.org/blog/post/209-PHP-55-Release-Date-Imminent--Lately-in-PHP-podcast-episode-36.html">PHP 5.5 Release Date Imminent - Lately in PHP podcast episode 36</a></div>
<div style="margin-top: 1ex">By Manuel Lemos</a></div>
<div style="margin-top: 1ex">The PHP 5.5.0 final release is about to happen. After about 16 months of development PHP 5.5 is bringing even more maturity to the PHP language, which by Google numbers is present in 75% of the Web sites.<br />
<br />
This was one of the main topics discussed by Manuel Lemos and Ernani Joppert in the episode 36 of the Lately in PHP podcast.<br />
<br />
They also discussed some new features proposed for PHP 5.6 like incremental decoding of large JSON data streams and overloading arithmetic operators for arbitrary precision math.<br />
<br />
They also debated the meaning of Google finally adding support to PHP in their cloud hosting platform Google AppEngine.<br />
<br />
Also in this episode it was discussed an article about good practices to quickly detect and fix PHP code bugs that only show up in production environments.<br />
<br />
Listen to the podcast, or watched the Google hangout video, or read the text transcript to learn more about these very interesting PHP topics.</a></div>
</div>
]]></content></entry><entry><title type="text">Packing a Symfony full-stack Framework Application in one File -- Introduction</title><link rel="alternate" type="text/html" href="http://feeds.fabien.potencier.org/~r/aidedecamp/~3/h84iTd2wDl4/packing-a-symfony-full-stack-framework-application-in-one-file-introduction" title="Packing a Symfony full-stack Framework Application in one File -- Introduction"/><link rel="shortlink" type="text/html" href="http://planet-php.org/~pog" title="Shortlink to http://feeds.fabien.potencier.org/~r/aidedecamp/~3/h84iTd2wDl4/packing-a-symfony-full-stack-framework-application-in-one-file-introduction"/><author><name>Fabien Potencier</name></author><id>http://fabien.potencier.org/article/69/packing-a-symfony-full-stack-framework-application-in-one-file-introduction</id><updated>2013-06-17T08:00:00Z</updated><published>2013-06-17T08:00:00Z</published><content type="html"><![CDATA[
    <blockquote class="note"><p>
  This article is part of a series of articles that explains how to pack a Symfony
  full-stack application in one file. The first article explains why this might actually
  be useful:
  1) <a href="http://fabien.potencier.org/article/69/packing-a-symfony-full-stack-framework-application-in-one-file-introduction">Introduction</a>,
  2) <a href="http://fabien.potencier.org/article/70/packing-a-symfony-full-stack-framework-application-in-one-file-bootstrapping">Bootstrapping</a>,
  ...</p>
</blockquote>

<p>Sometimes, I'm wondering if I'm not just completely crazy. I like small
things, but I'm the author of Symfony, a not-so-small framework (about eighty
thousand lines of code excluding comments as of today). And that's probably
because I like to push the limits of what's possible when coding.</p>

<p>In 1985, my first useful piece of code was about managing a portfolio of
stocks for my parents. I was twelve years old at that time. I won a contest.
It was an interesting challenge: coding a full game in less than <a href="http://fabien.potencier.org/article/32/developers-should-be-artists">10 lines of
code</a>.
And my code was published in a French magazine.</p>

<p>In 2009, I tweeted an implementation of a <a href="http://twittee.org/">dependency injection
container</a> in less than 140 characters (I did the same
with a <a href="http://twitto.org/">web framework</a>).</p>

<p>And most of the time, those experiments helped me get to the next level.
Twittee, my service container that fits in a Tweet, was an experiment, but
then, it became <a href="http://pimple.sensiolabs.org/">Pimple</a>, a small dependency
injection container that is used today in
<a href="http://silex.sensiolabs.org/">Silex</a>, a micro-framework based on the Symfony
components.</p>

<p>So, that's not about just trying to push the limits, or trying to have fun.
It's also about <strong>experimenting different approaches to known problems</strong> and
see if they can have practical usage.</p>

<p>So, 2013... time for another challenge, right? What about packing a Symfony
full-stack application in a single file. No Silex, no phar allowed, no
compilation phase, just everything in a single readable file: from assets to
controllers, from templates to Composer configuration.</p>

<h2>Why?</h2>

<p>This is yet another step toward my Quest of the PHP Holy Grail. But besides
being a though challenge, there are many other reasons that makes it
interesting for everyone.</p>

<p>First, that's a good way to learn more about the Symfony internals and
especially about the <a href="http://api.symfony.com/2.3/index.html">Kernel</a> class.
Nowadays, thanks to all the talks about HttpKernel given by various speakers
at various conferences, and thanks to my <a href="http://fabien.potencier.org/article/50/create-your-own-framework-on-top-of-the-symfony2-components-part-1">series of
articles</a>
about it on my blog, a lot of developers understand how Symfony handles
requests and how it manages the conversion to responses. There is even a full
<a href="http://symfony.com/doc/current/components/http_kernel/introduction.html">chapter</a>
about it in the official documentation.</p>

<p>But the Symfony Kernel is less well-known. This is a shame as it is also a
very interesting piece of software. I hope that this challenge will give you
more information about the Symfony Kernel and that, as a result, more
Open-Source projects will adopt it instead of just using the components.</p>

<p>Then, I want to showcase once more the flexibility of the Symfony core
framework and the decoupling between all aspects of the framework. If you are
just a Symfony developer, you might not realize how the low level architecture
of Symfony works, and I'm going to give you some insights about it.</p>

<p>Also, there is a more practical usage: <strong>bug reporting</strong>. When you report a
Symfony bug, sometimes, it is not that easy to reproduce it. Probably because
it involves third-party bundles, a specific configuration, or a chain of
controller calls. For such bugs, it is almost impossible to make a patch
without a way to reproduce it. As a matter of fact, we often ask reporters to
fork the Symfony Standard Edition and modify it in a way that exhibits the
issue. But doing so is tedious for both the reporter and the developer that
will try to fix the bug. Doing the same with Silex is more easier as most of
the time, the reporter is able to package everything is a single file. So,
being able to do the same with the full-stack framework would be a huge step
forward.</p>

<p>Reporting bugs is fine, but being able to experiment things in a small
environment also helps. A few weeks ago, Jordi submitted <a href="http://symfony.com/blog/new-in-symfony-2-4-customize-the-security-features-with-ease">a new API
layer</a>
to simplify the configuration of Symfony's Security. To better understand how
to use it and to get a feeling for the new API, I decided to create</p><p><i>Truncated by Planet PHP, read more at <a href="http://feeds.fabien.potencier.org/~r/aidedecamp/~3/h84iTd2wDl4/packing-a-symfony-full-stack-framework-application-in-one-file-introduction">the original</a> (another 2550 bytes)</i></p>]]></content></entry><entry><title type="text">Google Glass - A First Impression</title><link rel="alternate" type="text/html" href="http://blog.ircmaxell.com/2013/06/google-glass-first-impression.html" title="Google Glass - A First Impression"/><link rel="shortlink" type="text/html" href="http://planet-php.org/~pn0" title="Shortlink to http://blog.ircmaxell.com/2013/06/google-glass-first-impression.html"/><author><name>Anthony Ferrara</name></author><id>http://blog.ircmaxell.com/2013/06/google-glass-first-impression.html</id><updated>2013-06-17T00:49:00Z</updated><published>2013-06-17T00:49:00Z</published><content type="html"><![CDATA[<div style="text-align: justify;">This past Thursday evening I picked up my Explorer edition of <a href="http://www.google.com/glass/start/" rel="nofollow" target="_blank">Google Glass</a>. I was lucky enough to have my <a href="https://twitter.com/ircmaxell/status/304694344668020737" rel="nofollow" target="_blank">#ifihadglass tweet</a> chosen to receive the chance to pay an arm and a leg to get them. Needless to say, I did choose to pony up the cash, and on Thursday evening I walked home with my brand new piece of technology dangling off of my right temple. Since first impressions are often strong, but can be misleading, I chose to wait until I had used them for a few days before writing my thoughts. So here they are:</div><br><a href="http://blog.ircmaxell.com/2013/06/google-glass-first-impression.html#more">Read more »</a>]]></content></entry><entry><title type="text">Embedding REST Entities</title><link rel="alternate" type="text/html" href="http://qafoo.com/blog/048_embedding_rest_entities.html" title="Embedding REST Entities"/><link rel="shortlink" type="text/html" href="http://planet-php.org/~pk9" title="Shortlink to http://qafoo.com/blog/048_embedding_rest_entities.html"/><author><name>Qafoo - PHP</name></author><id>http://qafoo.com/blog/048_embedding_rest_entities.html</id><updated>2013-06-13T08:35:00Z</updated><published>2013-06-13T08:35:00Z</published><content type="html"><![CDATA[During my talk at IPC Spring I showed an approach for embedding entities in REST responses. This methodology might be useful if the standard use-case for your API is to request multiple related entities together. The downside of such an approach is the raised complexity of caching and especially purging logic. In this blog post I will further elaborate on the approach of resource embedding.
]]></content></entry><entry><title type="text">PHP: PECL/mysqlnd_ms 1.6 &#x2013; automatic retry loop for transient errors</title><link rel="alternate" type="text/html" href="http://blog.ulf-wendel.de/2013/php-peclmysqlnd_ms-1-6-automatic-retry-loop-for-transient-errors/" title="PHP: PECL/mysqlnd_ms 1.6 &#x2013; automatic retry loop for transient errors"/><link rel="shortlink" type="text/html" href="http://planet-php.org/~pkn" title="Shortlink to http://blog.ulf-wendel.de/2013/php-peclmysqlnd_ms-1-6-automatic-retry-loop-for-transient-errors/"/><author><name>Ulf Wendel</name></author><id>http://blog.ulf-wendel.de/?p=2202</id><updated>2013-06-12T09:56:00Z</updated><published>2013-06-12T09:56:00Z</published><content type="html"><![CDATA[<p>
<a href="http://php.net/mysqlnd_ms">PECL/mysqlnd_ms</a> is client-side load balancing driver plugin for PHP MySQL that aims to increase distribution transparency when using any MySQL based cluster: <a href="http://www.php.net/manual/en/mysqlnd-ms.quickstart.failover.php">failover</a>, <a href="http://www.php.net/manual/en/mysqlnd-ms.quickstart.usage.php">read-write splitting</a>, <a href="http://www.php.net/manual/en/mysqlnd-ms.quickstart.qos-consistency.php">abstraction on consistency (e.g. read-your-writes)</a>, <a href="http://www.php.net/manual/en/mysqlnd-ms.quickstart.partitioning.php">partitioning/sharding support</a>, … it’s all there. Until a few minutes ago, we had no special handling of transient errors. Sometimes a database server replies “come back in a bit and retry, no need to fail over yet”. And, that’s what the client shall do before giving up. PECL/mysqlnd_ms 1.6 (development version) is capable of hiding the retry loop, which makes it easier to use any existing PHP MySQL application with a cluster of MySQL servers.
</p>
<p>
Transient (temporary) errors are rarely observed with MySQL Replication but can be seen with <a href="http://dev.mysql.com/doc/refman/5.6/en/mysql-cluster.html">MySQL Cluster</a>. MySQL Cluster is an eager (synchronous) update anywhere (multi-master) cluster: all replicas accept reads and writes, replication is synchronous. See also the <strong>slide deck <a href="http://de.slideshare.net/nixnutz/diy-a-distributed-database-cluster-or-mysql-cluster">DIY: A distributed database cluster, or: MySQL Cluster</a></strong> for a brief introduction in distributed database theory relevant to MySQL users (presentation from the International PHP Conference 2013 Spring Edition).
</p>
<h3>Transient errors</h3>
<p>
<strong>MySQL Cluster scales well for write loads because it features transparent shardin</strong>g (see slides). It automatically partitions data over multiple replicas. Over the time, for example, when adding replicas to the cluster, data may b redistributed. Rebalancing is an online operation, it does not lock out clients. Thus, you may observe a temporary error such as:<br/><code/></p>
<pre>
ERROR 1297 (HY000): Got temporary error 1204 'Temporary
failure, distribution changed' from NDBCLUSTER 
</pre>
<p><br/>
There may be other causes for temporary errors as well. In any case, its safe to ignore a <a href="http://dev.mysql.com/doc/refman/5.6/en/error-messages-server.html#error_er_get_temporary_errmsg">1297/HY000</a> and retry the command.
</p>
<p>
The latest versions of MySQL Cluster feature an implicit retry loop before returning the error to the client, if it is believed that your command is not time critical. Means, Cluster resends the command for you a couple of times with a short sleep period in between before returning control to the client to tell about the temporary problem. PECL/mysqlnd_ms 1.6 alpha got a similar loop: very basic and experimental. Here’s the idea.
</p>
<h3>Automatic retry loop</h3>
<p>
The dream of Andrey when he created PECL/mysqlnd_ms was to make using a cluster transparent. It should be possible to move an application from a single MySQL to a cluster of MySQL servers without code changes. Thus, as a first step, I have opted against offering a callback to decide on errors (like Connector/J does). Instead, it is possible to configure the retry loop in the config file.
</p>
<p>
The example config snippet instructs the driver plugin to start an implcitiy command retry loop when there is an error with the error code 1297. Its possible to configure a list of arbitrary error codes. Whenever 1297 happens, the command is retried for <code>max_retries = 2</code> times. Between the retry attemps PECL/mysqlnd_ms 1.6 sleeps for <code>usleep_retry = 100</code> milliseconds. In an ideal world, the temporary error is gone by the end of the wait loop. In the worst case of the error persisting, it is forwarded to whatever PHP API you use (mysqli, PDO_MySQL) leaving it to your application to deal with it.<br/><code/></p>
<pre>
{
  "myapp": {
    [...]
    "transient_error": {
      "mysql_error_codes": [
        1297
      ],
      "max_retries": 2,
      "usleep_retry": 100
    }
  }
}
</pre>
<p><br/><strong>Please, send us your feature requests: this is a "live report" from the hacking and nothing is set. </strong>
</p>
<p>
You can check whether an implicit retry loop has been performed by inspecting the statistics provided by PECL/mysqlnd_ms.<br/><code/></p>
<pre>
$stats = mysqlnd_ms_get_stats();
printf("Implicit retries to hide transient errors: %d", 
  $stats['transient_error_retries']);
</pre>
<p>
</p>
<h3>Failover vs. transient error</h3>
<p>
When talking to a cluster instead of a single machine there are two additional error conditions to handle:</p>
<ul><li>Permanent error: replica disappeared, forget about replica – for now: fail over to someone else…</li>
<li>T</li></ul><p><i>Truncated by Planet PHP, read more at <a href="http://blog.ulf-wendel.de/2013/php-peclmysqlnd_ms-1-6-automatic-retry-loop-for-transient-errors/">the original</a> (another 1392 bytes)</i></p>]]></content></entry><entry><title type="text">Importing OpenStreetMap data into MongoDB</title><link rel="alternate" type="text/html" href="http://derickrethans.nl/importing-osm-into-mongodb.html" title="Importing OpenStreetMap data into MongoDB"/><link rel="shortlink" type="text/html" href="http://planet-php.org/~pjC" title="Shortlink to http://derickrethans.nl/importing-osm-into-mongodb.html"/><author><name>Derick Rethans</name></author><id>201306110949</id><updated>2013-06-11T08:49:00Z</updated><published>2013-06-11T08:49:00Z</published><content type="html"><![CDATA[<div class="article">
  <div class="body">
    <div class="articleListItem">
      <h1><a name="importing_openstreetmap_data_into_mongodb"/>Importing OpenStreetMap data into MongoDB</h1>
      <dl class="head"/><div class="articleMetaData">
        <div class="location"> London, UK</div>
        <div class="date">Tuesday, June 11th 2013, 09:49 BST</div>
      </div>
      <p>In many recent <a href="http://mongodb.org">MongoDB</a> related <a href="http://derickrethans.nl/talks.html">presentations</a> I have used <a href="http://openstreetmap.org">OpenStreetMap</a> data as basis for most of my examples. I wrote a script that imports OpenStreetMap (OSM) nodes, ways and to a lesser extend relations into MongoDB with a specific and optimal schema. I have written about this briefly before in <a href="http://derickrethans.nl/indexing-free-tags.html">Indexing Freeform-Tagged Data</a>, but now MongoDB received numerous updates to geospatial indexes I find it warrants a new article.</p>
      <p>In MongoDB 2.2 and before, the index type that MongoDB used was the <em>2d</em> type, which was basically a two dimensional flat earth coordinate system index—with some spherical features built on top. MongoDB 2.4 has a new index type: <em>2sphere</em>. Instead of just being able to index points described by x/y coordinates (longitude/latitude) it now has support for indexing points, <em>line strings</em> and <em>polygons</em> as defined by <a href="http://www.geojson.org/">GeoJSON</a>.</p>
      <p>I have modified my import script to use those new types, and also added support for very simple multi-polygons that OpenStreetMap records through its <em>relation</em> tag. The script also creates an indexes on <em>{ l: '2dsphere' }</em> (the GeoJson object), <em>{ ts: 1 }</em> (the tags), and <em>{ ty: 1 }</em> (the type).</p>
      <p>The structure it converts a <a href="http://www.openstreetmap.org/browse/node/26486695">node</a> from OpenStreetMap to looks like:</p>
      <pre>{
        "_id" : "n26486695",
        "ty" : NumberLong(1),
        "l" : {
                "type" : "Point",
                "coordinates" : [
                        -0.1580359,
                        51.4500055
                ]
        },
        "ts" : [
                "addr:housenumber=97",
                "addr:postcode=SW12 8NX",
                "addr:street=Nightingale Lane",
                "amenity=pub",
                "name=The Nightingale",
                "operator=Youngs",
                "source:name=photograph",
                "toilets=yes",
                "toilets:access=customers",
                "website=http://www.youngs.co.uk/pub-detail.asp?PubID=430"
        ],
        "m" : {
                "v" : NumberLong(5),
                "cs" : NumberLong(11229430),
                "uid" : NumberLong(652021),
                "ts" : NumberLong(1333911628)
        }
}

</pre>
      <p>There are several sections that make up the document:</p>
      <ul><li>
          <p><em>_id</em>: Is a combination of <em>n</em> and the OSM node id.</p>
        </li>
        <li>
          <p><em>ty</em>: Is the type. For nodes, this is always <em>1</em>.</p>
        </li>
        <li>
          <p><em>l</em>: The point's location in GeoJson format. An OSM point is translated to a GeoJson <em>Point</em> feature with an array describing the longitude and latitude.</p>
        </li>
        <li>
          <p><em>ts</em>: Are the tags that describe the node. Each tag is stored as a concatenation of its <em>key</em> and its <em>value</em>. This creates both a smaller index and it still allows for exact tag/value matches as well as matching against specfic keys through a regular expression match. For example, we could find the above document with:</p>
          <p>
            <code>db.poiConcat.find( { ts: 'name=The Nightingale' } );</code>
          </p>
          <p>And the index would also be used when we look for all amenities:</p>
          <p>
            <code>db.poiConcat.find( { ts: /^amenity=/ } );</code>
          </p>
        </li>
        <li>
          <p><em>m</em>: Contains meta information that describes the node. The following fields are currently present:</p>
          <ul><li>
              <p><em>v</em>: The object's version. This is the version number of the version that was found in the imported file. There is always just one version per object.</p>
            </li>
            <li>
              <p><em>cs</em>: The changeset ID in which this object was last updated.</p>
            </li>
            <li>
              <p><em>uid</em>: The user ID of the OpenStreetMap contributor who uploaded the latest version.</p>
            </li>
            <li>
              <p><em>ts</em>: The Unix timestamp of when this object was last updated.</p>
            </li>
          </ul></li>
      </ul><p>OpenStreetMap ways are stored in two different types. <a href="http://www.openstreetmap.org/brow&lt;/body>"/></p></div></div></div><p><i>Truncated by Planet PHP, read more at <a href="http://derickrethans.nl/importing-osm-into-mongodb.html">the original</a> (another 2929 bytes)</i></p>]]></content></entry><entry><title type="text">Speaking at Conferences: How to write a talk and get it accepted</title><link rel="alternate" type="text/html" href="http://daveyshafik.com/archives/68081-speaking-at-conferences-how-to-write-a-talk-and-get-it-accepted.html" title="Speaking at Conferences: How to write a talk and get it accepted"/><link rel="shortlink" type="text/html" href="http://planet-php.org/~piL" title="Shortlink to http://daveyshafik.com/archives/68081-speaking-at-conferences-how-to-write-a-talk-and-get-it-accepted.html"/><author><name>Davey Shafik</name></author><id>http://daveyshafik.com/?p=68081</id><updated>2013-06-10T09:22:00Z</updated><published>2013-06-10T09:22:00Z</published><content type="html"><![CDATA[<p class="lead">After <a href="http://tek13.phparch.com">php[tek]</a> this year (and the awesome mentorship summit), I wrote up a blog post detailing how I go about creating proposals, as well as giving some insight into how we chose proposals for <a href="http://distill.engineyard.com">Distill</a>.</p>

<p>You can read that blog post on the <a href="https://blog.engineyard.com/2013/speaking-at-conferences">Engine Yard Blog</a>.</p>
]]></content></entry></feed>
