<?xml version="1.0"?>
<?xml-stylesheet 
 href="http://www.w3.org/2000/08/w3c-synd/style.css" type="text/css"
?>
<rss version="0.91"><channel><title>Planet PHP</title><link>http://planet-php.net</link><description>People blogging about PHP</description><language>en</language><item><title>URL Shorteners - Florian Anderiasch</title><link>http://codeschmie.de/archives/301-URL-Shorteners.html</link><pubDate>Thu, 02 Jul 2009 22:57:19 +0000</pubDate><description><![CDATA[
    Yes, it's the new hype - URL shorteners (mostly for use in Twitter).<br />
Some use the classic <a href="http://tinyurl.com">tinyurl</a>, then there's <a href="http://is.gd">is.gd</a> and <a href="http://bit.ly">bit.ly</a> and a fair bunch of others.<br />
<br />
As some people already wrote, and I feel no different here, broken links are baaad, mkay?<br />
So the easiest way would be to get a short domain for yourself and run your own url shortener.<br />
I am happy enough to have secured myself a not yet publicly announced 3-char .de domain which 
I'm planning to use for that. This and being bored for 2h led me to roll out my own shortening service.<br />
<br />
Enter Shortcore - 259 lines of php code, working already. <br />
It needs PHP 5.2.0+ (I think :P) and sqlite and I've put it up on <a href="http://github.com/winks/shortcore/tree">github</a> - it's BSD licenced and comments and patches are very much appreciated.<br />
<br />
How to use it when it's installed:<br />
<ul>
<li>http://example.org/_[uniqueid] redirects to what you saved.</li>
<li>http://example.org/_[uniqueid]_ shows a preview</li>
<li>So I have "xxx.de/_ab" - as low as 10 chars for an url (excluding http://), that's not less than a bit.ly url (currently at 5+ chars after the /) and I can still put normal content (not starting with a  "_") on the domain - fair deal I think</li>
<li>there's a bookmarklet for easy saving, either provide the [uniqueid] or let it be generated automatically</li>
<li>it's not meant as a public shortening service, so probably some basic auth has to be added</li>
</ul>  
    ]]></description></item><item><title>Status Codes for Web Services - Lorna Mitchell</title><link>http://www.lornajane.net/posts/2009/Status-Codes-for-Web-Services</link><pubDate>Thu, 02 Jul 2009 14:44:00 +0000</pubDate><description><![CDATA[
    <i>This the last entry in a mini series on points to consider when designing and building web services.  So far there have been posts on <a href="http://www.lornajane.net/posts/2009/Error-Feedback-for-Web-Services">error feedback for web services</a>, <a href="http://www.lornajane.net/posts/2009/Auth-Mechanisms-for-Web-Services">auth mechanisms for web services</a>, <a href="http://www.lornajane.net/posts/2009/Saving-State-in-a-Web-Service">saving state in web services</a> and <a href="http://www.lornajane.net/posts/2009/Version-Parameters-for-Web-Services">using version parameters with web services</a></i>.<br />
<br />
Unlike the other posts in this series, this one is quite specific to one type of service - REST - since it deals with status codes, specifically HTTP ones.  The ideas are transferrable however and other types of service can return statuses in a similar way.<br />
<br />
There's a few key things to think about when returning status codes.  In earlier posts in this series these was discussion of using existing application framework to serve pages and changing the output mechanism accordingly.  Usually a web page will return a status 200 for OK or also 302 for found, so this is fine when things are working normally.  But when things aren't going quite so well, its useful to give alternative feedback that can be easily picked up by a client application.<br />
<br />
When things go wrong there are a couple of different schools of thought of how the service should respond.  One is that if, for example, the user supplies data which fails validation, the service could provide the OK response and a message to the user to let them know what needs validating - exactly as we'd return information messages to a user filling in a form.  To be considered restful however, the service should more correctly return one of the "400" status codes, which means that the client made an error.  Interesting and useful codes* in this series are:<br />
<ul><br />
<li>401 Unauthorized</li><br />
<li>403 Forbidden</li><br />
<li>404 Not Found</li><br />
<li>405 Method Not Allowed</li><br />
<li>406 Not Acceptable</li><br />
<li>408 Request Timeout</li><br />
<li>417 Expectation Failed</li><br />
<li>418 I'm a teapot</li><br />
</ul><br />
<i>* I didn't say they were both useful and interesting</i><br />
<br />
Using descriptive status codes allows the client to get the headline of the problem without having to parse a whole request to find out whether it is good or not.  HTTP already has this feature built-in, and so we make use of it (HTTP is pretty cool really, makes a great protocol for services!).<br />
<br />
Where an error occurs on the server side - it is usual to return a 500 error or another in the 500 series.  This lets the client know there is a problem outside of their control; it is useful to include information about whether the client should retry and when.  Having a defined protocol for retries helps avoid the situation where a system comes back up only to fall over again with all the traffic from people retrying every minute (or other interval) - this is a real concern for systems that are under heavy load.<br />
<br />
Status codes are like a headline to the calling entity about what happened, and are a valuable tool in the web service toolkit.  For bonus points, leave me a comment and tell me which is your favourite status code :)  
    ]]></description></item><item><title>OSS projects at Liip - Lukas Smith</title><link>http://pooteeweet.org/blog/0/1511</link><pubDate>Thu, 02 Jul 2009 13:07:04 +0000</pubDate><description><![CDATA[<p>Yesterday we had an <a href="http://www.flickr.com/photos/chregu/sets/72157620851230340/">entire day at Liip</a> dedicated to various talks, workshops and hanging out together. It really reminded me again what an amazing company <a href="http://liip.ch">Liip</a> is. Its really what I wished m company back in Berlin should have been. Fun, smart, successful, productive, agile, good. At any rate I wanted to mention the stuff we are working on in terms of OSS. Obviously Chregu and myself are active on PHP. Jordi is also an active member of the PHP.net community. But we have other less known stuff that should also get noted, like Jackalope, Mahara, Picok, GottaGo and Okapi.</p>

<p><a href="https://fosswiki.liip.ch/display/jackalope/Home">Jackalope</a> is an implementation of the client side JCR standard for PHP. This will enable us making happy agile frontends that are managed with all the various Enterprise features like versioning, ACL's etc. Liip created this project but is looking for others to join. We are already sharing the interfaces with the typo3 guys.</p>

<p><a href="http://mahara.org">Mahara</a> is a social networking platform that has spawned out of the Moodle e-learning community. Penny recently joined Liip and she was actually one of the original founders of the project.</p>

<p><a href="http://picok.org">Picok</a> is a one of my babies. Its sort of an OSS iGoogle. So it allows you to easily create new so called portlets, that can aggregate content from various internal and external data sources and present them in a user customizable interface. Originally created for one of our clients the Raiffeisen Bank here in Switzerland. They were kind enough to let us open source the code. In return we won them a couple prizes at the <a href="http://www.liip.ch/news/archive/2009/04/06/best-of-swiss-web-2009.html">Swiss Web Awards</a> :)</p>

<p>GottaGo actually took the Swiss Web Awards by storm. It won the grand prize along with a few other category prizes. Its an iPhone app that basically finds the fasted route via public transportation from point A to B here in Switzerland. Oh and I should stop referring to it as GottaGo, since its now called <a href="http://codesofa.com/code/transport">"Transport"</a>.</p>

<p><a href="http://okpai.liip.ch">Okapi</a> is our super lightweight framework. Recently Chregu and I have started working on version 2. Basically we took various Symfony2 components and integrated them into our code. Currently its still in proof of concept stage, but it looks quite promising. I am really seeing a lot of potential in the service container and event dispatcher. I also think it could become a very useful addition to the Symfony eco-system as it seems quite feasible to migrate from Okapi2 to Symfony2 or vice versa. Meaning it will be able to choose if you want something simple and lean or you need something full features, without having to need to learn two totally different frameworks. Chregu has ported <a href="http://liip.to">liip.to</a> to this proof of concept, so <a href="https://svn.liip.ch/repos/public/misc/liipto/branches/okapi2/">check it out</a>!</p>

]]></description></item><item><title>Learn PHP The Easy Way - SitePoint &#xC2;&#xBB; PHP</title><link>http://www.pheedcontent.com/click.phdo?i=e98e6c21c68477f2dede7a401df9dda1</link><pubDate>Thu, 02 Jul 2009 10:48:44 +0000</pubDate><description><![CDATA[<p><img class="imgright" src="http://www.sitepoint.com/images/books/phpmysql4/cover.jpg" alt="PHPMYSQL4 Cover" /><br />
With over 40,000 copies sold of the three previous editions, I’m very pleased to announce the latest title hot off the SitePoint production line:</p>
<p><strong><a href="http://www.sitepoint.com/books/phpmysql4/">Build Your Own Database Driven Web Site Using PHP & MySQL (4th Edition)</a></strong> — by Kevin Yank</p>
<p>One of the most popular PHP books for beginners, this shiny new 4th edition has been completely updated using only best-practice PHP.  </p>
<p>In this book you’ll learn how to:</p>
<div id="adz" class="vertical"></div><ul>
<li>install PHP 5 and MySQL 5 on Windows, Linux, or Mac OS X</li>
<li>gain a thorough understanding of PHP syntax</li>
<li>master database design principles and SQL</li>
<li>build a working content management system</li>
<li>add, edit, and delete web content without using html</li>
<li>create an ecommerce shopping cart</li>
<li>utilize sessions and cookies to track site visitors</li>
<li>craft SEO-friendly and memorable URLs</li>
</ul>
<p>And a whole lot more … </p>
<p>At around 480 pages, this book is an easy read. As you move through the book you’ll quickly notice that it’s written in a clear tutorial format that’s easy to understand, and illustrated with plenty of screenshots and diagrams, providing quick visual cues. If you hate wading through dry, academic-style “how to” texts, this book will be a breath of fresh air to you.</p>
<p>If you’ve never built a database driven web site and you’re looking to go beyond the limitations of a static site, this book will start you off in no time. </p>
<p>And if you have built database driven web sites before, the extensive PHP/MySQL reference guides included will ensure this book remains an extremely handy desk reference.</p>
<p>Check out the <a href="http://www.sitepoint.com/books/phpmysql4/samplechapters.php">free sample chapters</a> or <a href="https://sitepoint.com/bookstore/go/157">order a copy today</a>.</p>
&lt;script src="http://ads.aws.sitepoint.com/adjs.php?region=136&did=adz&adtype=vertical" type="text/javascript"></script><br clear="both" style="clear: both;"/>
<br clear="both" style="clear: both;"/>
<a href="http://ads.pheedo.com/click.phdo?s=e98e6c21c68477f2dede7a401df9dda1&p=1"><img alt="" style="border: 0;" border="0" src="http://ads.pheedo.com/img.phdo?s=e98e6c21c68477f2dede7a401df9dda1&p=1"/></a>
]]></description></item><item><title>Software patents are silly - Henri Bergius</title><link>http://bergie.iki.fi/blog/software_patents_are_silly/</link><pubDate>Thu, 02 Jul 2009 10:13:46 +0000</pubDate><description><![CDATA[
<p>
<a href="http://blogs.gnome.org/bolsh/2009/07/02/why-i-disagree-with-rms-concerning-mono/">Dave Neary summed this up</a> well:
</p>

<blockquote>
...I fundamentally disagree with discouraging someone from pursuing a technology choice because of the threat of patents. In this particular case, the law is an ass. The patent system in the United States is out of control and dysfunctional, and it is bringing the rest of the world down with it. The time has come to take a stand and say “We don’t care about patents. We’re just not going to think about them. Sue us if you want.”
</blockquote>

<p>
With <a href="http://www.midgard-project.org/">Midgard</a> we <a href="http://bergie.iki.fi/blog/2004-06-17-000/">have prior art on some software patents</a>. Software patents only promote big multinational monopolies, and therefore are <a href="http://bergie.iki.fi/blog/eu_agriculture_ministers_threaten_again_with_software_patents/">against the interests of both Europe and the Free Software movement</a>. They're silly, <a href="http://bergie.iki.fi/blog/no-to-european-software-patents/">don't apply here</a>, and therefore the only rational response is to ignore them.
</p>



<p style="text-align:right;font-size:10px;">Technorati Tags: <a href="http://www.technorati.com/tag/softwarepatents" rel="tag">softwarepatents</a></p>


]]></description></item><item><title>Scalar type hints in PHP - Tobias Schlitt</title><link>http://schlitt.info/opensource/blog/0712_scalar_type_hints_in_php.html</link><pubDate>Thu, 02 Jul 2009 08:29:54 +0000</pubDate><description><![CDATA[Ilia recently brought up the topic of scalar type hints again. I would love
scalar type hints, but a sensible implementation is not easy. I summarize some
approaches in this post and talk about the problems they raise.]]></description></item><item><title>ORMs vs. Query Builders: Database portability - Larry Garfield</title><link>http://www.garfieldtech.com/blog/orm-vs-query-builders</link><pubDate>Thu, 02 Jul 2009 03:59:04 +0000</pubDate><description><![CDATA[<p>There has been some discussion in recent days regarding Object-Relational Mappers (ORMs), Drupal, and why the latter doesn't use the former.  There are, actually, many reasons for that, and for <a href="http://groups.drupal.org/node/8001">why Drupal doesn't do more with the Active Record pattern</a>.</p>
<p>Rather than tuck such discussion away in an issue queue, I figured it better to document a bit more widely.</p>
<p><a href="http://www.garfieldtech.com/blog/orm-vs-query-builders" target="_blank">read more</a></p>]]></description></item><item><title>Get a Free iPhone: Help SitePoint Recruit a PHP Developer - SitePoint &#xC2;&#xBB; PHP</title><link>http://www.pheedcontent.com/click.phdo?i=f2c2a7b73c3c334bb8d720d856f37cd8</link><pubDate>Thu, 02 Jul 2009 03:23:09 +0000</pubDate><description><![CDATA[<p><img src="http://i2.sitepoint.com/images/sitepointlogo150.png" alt="" class="imgright" /></p>
<p><strong>SitePoint is looking for two experienced PHP developers (one with a sysadmin twist) to join the team here at SitePoint HQ in Melbourne, Australia. Help us find the right person for either of these positions, and we’ll buy you a shiny, new iPhone 3GS!</strong></p>
<p>Know someone with “mad PHP skillz” who either lives in Melbourne or would move here for the opportunity to work on one of the Web’s major destination sites for web developers and designers? Drop me an email with the details at <strong>kevin(at)sitepoint.com</strong>.</p>
<p>Of course, if you would just like to apply for the position yourself, the complete position descriptions are in our <a href="http://www.sitepoint.com/about/jobs/">jobs section</a>.</p>
<br clear="both" style="clear: both;"/>
<br clear="both" style="clear: both;"/>
<a href="http://ads.pheedo.com/click.phdo?s=f2c2a7b73c3c334bb8d720d856f37cd8&p=1"><img alt="" style="border: 0;" border="0" src="http://ads.pheedo.com/img.phdo?s=f2c2a7b73c3c334bb8d720d856f37cd8&p=1"/></a>
]]></description></item><item><title>My favorite language (code) - Terry Chay</title><link>http://terrychay.com/blog/article/my-favorite-language-code.shtml</link><pubDate>Wed, 01 Jul 2009 23:21:19 +0000</pubDate><description><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Internationalization_and_localization" title="Internationalization and Localization—Wikipedia">Internationalizing</a> the a website, you run into a problem where you don’t know what strings you’ve parsed out for localization or not.</p>
<p>For these tasks, my favorite language is “<a href="http://en.wikipedia.org/wiki/ISO_639" title="ISO 639—Wikipedia. XZZ is a code to declare the absence of linguistic information" class="commentary">zxx</a>.” I use that code to replace all strings with some XX’s. Now any strings (or images) I missed are immediately evident.</p>
<div class="flimg" style="width:500px"><a href="http://www.flickr.com/photos/tychay/3676781826/" title="Meetme Play — Tagged (in zxx_XX) by tychay, on Flickr"><img src="http://farm3.static.flickr.com/2536/3676781826_943ee67382.jpg" width="500" height="391" alt="Meetme Play — Tagged (in zxx_XX)"/></a></div>
<p><span id="more-2279"/></p>
<p>Keeping the zxx localization file up to date is easy to update…</p>
<pre class="brush: php;">
// {{{ l10n_upgrader($pofile,$callback)
/**
 * Allows you to upgrade a PO file automatically.
 *
 * Search for all "" (two double quotes) and translate these.
 *
 * @param string $pofile the messages.po file to upgrade
 * @param string $callback the callback function that does the string lookup
 * @return array
 */
function l10n_upgrader($pofile,$callback='')
{
    if ($callback) {
        $data = file_get_contents($pofile);
        $matches = array();
        $data = preg_replace_callback("!^msgid \"(.+?)\"\nmsgstr \"\"!m", $callback, $data); // if I add s it matches too aggressively
        //unlink($pofile);
        file_put_contents($pofile,$data);
    }
    // generate output
    //msgfmt message.po
    $exec = sprintf(
        'cd %s;msgfmt %s',
        escapeshellarg(dirname($pofile)),
        escapeshellarg('messages.po')
    );
   pass($exec); //erroring out this is an exec function
}
// }}}
// {{{ l10n_ZXXer($matches)
/**
 * Add a bunch of XXXX's to a string
 *
 * @param array $matches
 * @return string
 */
function l10n_ZXXer($matches)
{
    return sprintf(
        "msgid \"%s\"\nmsgstr \"%s\"",
        $matches[1],
        str_pad('',strlen($matches[1]),'XXXX ')
    );
}
// }}}
l10n_upgrader($gt_dird.'zxx_XX/LC_MESSAGES/messages.po', 'l10n_ZXXer');
</pre>
<p>You may have some trouble getting things working, so remember that gettext uses your system to set the language. If your system doesn’t have zxx installed, you can’t just flip your locale over and expect it to work. As a quick hack for develement, just symlink the directory in your dev machine over to <span title="To see what languages are installed, type “locale -a” in the Unix shell." class="commentary">a language you aren’t using</span>. I’m currently using “zu_ZA” which will be okay until Tagged localizes for <a href="http://en.wikipedia.org/wiki/Zulu_language" title="Zulu language—Wikipedia">Zulu</a>.</p>
<p>Also remember that your web server caches gettext strings, so be sure to shut down the webserver to free the file lock before updating <a href="http://en.wikipedia.org/wiki/Gettext" title="GNU gettext—Wikipedia">your .pot file</a>.</p>
<h3>Improving your linguisticness</h3>
<p><code>l10n_ZXXer()</code> above is not that clever. It won’t handle the cases where you have nested sprintf() substitutions. But you can imagine improving it. Here are some ideas of different fake languages:</p>
<ul><li>Multiply <code>strlen()</code> computation by 1.2 in order to handle spacing issues for localizing to German.</li>
<li>Replace many of the letters with the letters in the <a href="http://en.wikipedia.org/wiki/Russian_alphabet" title="Russian alphabet—Wikipedia">cyrillic alphabet</a>. This way you know unicode is correctly supported. <a href="http://www.flickr.com/photos/tychay/3679530323/" title="Tagged in fake russian—tychay@Flickr. Do you see it?" class="commentary">Don’t replace all of them</a> so your pattern replace can be easier and strings don’t get smashed.
<div class="flimg" style="width:493px"><a href="http://www.flickr.com/photos/tychay/3679530323/" title="Tagged in fake russian by tychay, on Flickr"><img src="http://farm3.static.flickr.com/2545/3679530323_81ca17c69c.jpg" width="439" height="500" alt="Tagged in fake russian"/></a></div>
</li>
<li>Replace the code to run it through a filter so it’s linguistically recognizable. Maybe turn your site into 133t-speak. Personally, I used ebonics from my Plaxo days. Careful though, while it is amusing to see <span title="Especially Tagged" class="commentary">your website</span> littered with argot, fo’ shizzle. Apparently, I was committing a lot of cuss words into the code base. It’s times like that you’re grateful for the symlink trick above preventing your users from stumbling on these fake languages.
<div class="flimg" s=""/></li></ul><p><i>Truncated by Planet PHP, read more at <a href="http://terrychay.com/blog/article/my-favorite-language-code.shtml">the original</a> (another 1347 bytes)</i></p>]]></description></item><item><title>Yes, PHP 5.3 is here.  What does that mean? - Christopher Jones</title><link>http://blogs.oracle.com/opal/2009/07/yes_php_53_is_here_what_does_t.html</link><pubDate>Wed, 01 Jul 2009 19:06:50 +0000</pubDate><description><![CDATA[
        Yesterday PHP 5.3 was released. It can be downloaded from the PHP site. This release has been the product of combined efforts from all areas of the community. While core PHP language developers may have the public profile of soccer...
        ]]></description></item></channel></rss>
