<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" >
<channel>
    
    <title>/dev/weblog - PHP</title>
    <link>https://devweblog.org/</link>
    <description>Technical drivel.</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.6.2 - http://www.s9y.org/</generator>
    <pubDate>Sun, 09 Aug 2015 07:17:44 GMT</pubDate>

    <image>
        <url>https://devweblog.org/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: /dev/weblog - PHP - Technical drivel.</title>
        <link>https://devweblog.org/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Country Codes</title>
    <link>https://devweblog.org/archives/55-Country-Codes.html</link>
            <category>PHP</category>
    
    <comments>https://devweblog.org/archives/55-Country-Codes.html#comments</comments>
    <wfw:comment>https://devweblog.org/wfwcomment.php?cid=55</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>https://devweblog.org/rss.php?version=2.0&amp;type=comments&amp;cid=55</wfw:commentRss>
    

    <author>nospam@example.com (Double Compile)</author>
    <content:encoded>
    &lt;p&gt;Just to bump the visibility, I added two GitHub gists that you might find useful.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;One is a &lt;a href=&quot;https://gist.github.com/doublecompile/3ff937a22626113747fb&quot;&gt;JSON file containing all ISO 3166-1 alpha-2 country codes as of 2013&lt;/a&gt;, sorted by code.&lt;/li&gt;
&lt;li&gt;The other is a &lt;a href=&quot;https://gist.github.com/doublecompile/9cbc05f845d9d5ed8e93&quot;&gt;PHP file containing an array of all ISO 3166-1 alpha-2 country codes as of 2013&lt;/a&gt;, sorted by name.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Cheers!&lt;/p&gt; 
    </content:encoded>

    <pubDate>Thu, 06 Aug 2015 21:57:58 +0000</pubDate>
    <guid isPermaLink="false">https://devweblog.org/archives/55-guid.html</guid>
    <category>php</category>
<creativeCommons:license>http://creativecommons.org/licenses/by-sa/3.0/</creativeCommons:license>
</item>
<item>
    <title>Number of the beast</title>
    <link>https://devweblog.org/archives/41-Number-of-the-beast.html</link>
            <category>PHP</category>
    
    <comments>https://devweblog.org/archives/41-Number-of-the-beast.html#comments</comments>
    <wfw:comment>https://devweblog.org/wfwcomment.php?cid=41</wfw:comment>

    <slash:comments>1</slash:comments>
    <wfw:commentRss>https://devweblog.org/rss.php?version=2.0&amp;type=comments&amp;cid=41</wfw:commentRss>
    

    <author>nospam@example.com (Double Compile)</author>
    <content:encoded>
    &lt;p&gt;As it turns out, the &lt;a href=&quot;https://secure.wikimedia.org/wikipedia/en/wiki/Number_of_the_Beast&quot;&gt;Number of the Beast&lt;/a&gt; isn&#039;t 666.&lt;/p&gt; 
&lt;p&gt;… it&#039;s &lt;a href=&quot;http://www.zend.com/en/company/news/news-links/php-remote-exploit-information-and-hotfix&quot;&gt;2.2250738585072011&lt;sup&gt;e-308&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt; 
    </content:encoded>

    <pubDate>Thu, 06 Jan 2011 17:23:21 +0000</pubDate>
    <guid isPermaLink="false">https://devweblog.org/archives/41-guid.html</guid>
    <category>math</category>
<category>php</category>
<category>security</category>
<creativeCommons:license>http://creativecommons.org/licenses/by-sa/3.0/</creativeCommons:license>
</item>
<item>
    <title>No More PHP 4, Pt 3: Play Nice with Authentication</title>
    <link>https://devweblog.org/archives/17-No-More-PHP-4,-Pt-3-Play-Nice-with-Authentication.html</link>
            <category>PHP</category>
    
    <comments>https://devweblog.org/archives/17-No-More-PHP-4,-Pt-3-Play-Nice-with-Authentication.html#comments</comments>
    <wfw:comment>https://devweblog.org/wfwcomment.php?cid=17</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>https://devweblog.org/rss.php?version=2.0&amp;type=comments&amp;cid=17</wfw:commentRss>
    

    <author>nospam@example.com (Double Compile)</author>
    <content:encoded>
    
&lt;p&gt;PHP 4 is end-of-life very soon. In addition to offering projects the chance to refactor and improve their application design, PHP 5 offers many things PHP 4 just doesn&#039;t. This series of posts will deal with things projects can get their fingers into that will benefit everyone.&lt;/p&gt;
&lt;p&gt;The third: play nice with authentication.&lt;/p&gt;
&lt;p&gt;Your application isn&#039;t the only kid on the block, especially if it&#039;s a single-purpose application like a forum or an issue tracker.  Nothing is more frustrating than having to hack your application so my users don&#039;t have to login to different parts of my Web site.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://killersoft.com/randomstrings/&quot;&gt;Clay Loveless&lt;/a&gt; made a post in June of &#039;06 stressing &lt;a href=&quot;http://killersoft.com/randomstrings/2006/06/14/stop-writing-loner-applications/&quot;&gt;the stupidity of &amp;quot;loner applications&amp;quot;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can remedy your application&#039;s isolation using one of two things: &lt;a href=&quot;http://openid.net&quot;&gt;OpenID authentication&lt;/a&gt; or some kind of authentication plugin API or adapter.&lt;/p&gt;
&lt;p&gt;Implementing OpenID is perhaps the lesser solution.  Users would still have to put their OpenID address into each application on a site to login; it&#039;s not nearly as bad as having separate passwords, but still less convenient than a unified sign-on.&lt;/p&gt;
&lt;p&gt;The preferred solution to this mess is to provide an API for others to write pluggable authentication modules and then pick which one is being used in a configuration somewhere.  I applaud &lt;a href=&quot;http://wiki.splitbrain.org/wiki:dokuwiki&quot;&gt;DokuWiki&lt;/a&gt; for their very simple and effective implementation of such an adapter.  I also have experience with MediaWiki&#039;s plugin system, but don&#039;t get me started on the MediaWiki source code.  Mantis has a decent start on an authentication plugin, but it still leaves much to be desired.&lt;/p&gt;
&lt;p&gt;If you&#039;re going to start an authentication adapter system from scratch, may I suggest &lt;kbd&gt;&lt;a href=&quot;http://framework.zend.com/manual/en/zend.auth.html&quot;&gt;Zend_Auth&lt;/a&gt;&lt;/kbd&gt;?  Adapters are a breeze to implement and &lt;kbd&gt;Zend_Auth&lt;/kbd&gt; takes care of persisting a user&#039;s session.  If you&#039;re using the &lt;kbd&gt;Zend_Controller&lt;/kbd&gt; MVC, may I also suggest &lt;kbd&gt;&lt;a href=&quot;http://xyster.devweblog.org/documentation/guide/xyster.controller.plugins.html#xyster.controller.plugins.auth&quot;&gt;Xyster_Controller_Plugin_Auth&lt;/a&gt;&lt;/kbd&gt;?  It gives you the ability to specify the MVC dispatch locations for login prompting, success, and failure.&lt;/p&gt;
&lt;p&gt;Actually, adapters and plugins are a good idea for &lt;em&gt;any&lt;/em&gt; software.  If I have to edit a single source file for your application, you&#039;re doing a poor job at keeping extensibility in mind.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Tue, 22 Jan 2008 16:00:54 +0000</pubDate>
    <guid isPermaLink="false">https://devweblog.org/archives/17-guid.html</guid>
    <category>authentication</category>
<category>no more php4</category>
<category>openid</category>
<category>php</category>
<creativeCommons:license>http://creativecommons.org/licenses/by-sa/3.0/</creativeCommons:license>
</item>
<item>
    <title>No More PHP 4, Pt. 2: Stop Using Global Variables</title>
    <link>https://devweblog.org/archives/10-No-More-PHP-4,-Pt.-2-Stop-Using-Global-Variables.html</link>
            <category>PHP</category>
    
    <comments>https://devweblog.org/archives/10-No-More-PHP-4,-Pt.-2-Stop-Using-Global-Variables.html#comments</comments>
    <wfw:comment>https://devweblog.org/wfwcomment.php?cid=10</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>https://devweblog.org/rss.php?version=2.0&amp;type=comments&amp;cid=10</wfw:commentRss>
    

    <author>nospam@example.com (Double Compile)</author>
    <content:encoded>
    &lt;p&gt;PHP 4 is end-of-life very soon. In addition to offering projects the chance to refactor and improve their application design, PHP 5 offers many things PHP 4 just doesn&#039;t. This series of posts will deal with things projects can get their fingers into that will benefit everyone.&lt;/p&gt;

&lt;p&gt;The second: stop using global variables; I mean it.&lt;/p&gt;

&lt;p&gt;If there&#039;s one thing that really gets under my skin, it&#039;s the use of the global variable scope to store all kinds of things that just shouldn&#039;t be there.  I&#039;ve seen everything from lengthy configuration settings to global arrays for event hooks (I&#039;m looking at you, MediaWiki).  There are several reasons using globals is a bad idea, but I&#039;ll point out two important ones.&lt;/p&gt;

&lt;p&gt;First, it&#039;s a vulnerability.  The problem is that variables in the global scope are just that: globally available to be read from and written to by every line of code.  A great security risk comes into play when sensitive information like usernames and passwords are available to your entire application or can be easily overwritten.  What happens when an important global variable containing an array is overwritten to be a string?  Whoops!  The whole application just broke.&lt;/p&gt;

&lt;p&gt;Second, it&#039;s sloppy.  Putting values in the global scope so they can be accessed by your functions is hackish and ugly.  It leads to problems with maintenance and debugging.  If you have 500 functions that access a single global variable, you have to edit every last reference to it if you ever refactor your code.  Consider what happens when you want to embed one application within another and they both happen to reference a global variable with the same name: mass hysteria.&lt;/p&gt;

&lt;p&gt;What should you do, you ask?  &lt;a href=&quot;http://weierophinney.net/matthew/&quot;&gt;Matthew Weier O&#039;Phinney&lt;/a&gt; made some good suggestions in &lt;a href=&quot;http://weierophinney.net/matthew/archives/138-Start-Writing-Embeddable-Applications.html&quot;&gt;an entry about Embedding Applications&lt;/a&gt;.  He says use static properties or singletons to store your globally available settings; both good ideas.  Let&#039;s go over two examples I brought up earlier and how to fix them.&lt;/p&gt;

&lt;p&gt;Configuration settings should be loaded from and accessed through a configuration class; &lt;a href=&quot;http://framework.zend.com/manual/en/zend.config.html&quot;&gt;Zend_Config&lt;/a&gt;, &lt;a href=&quot;http://pear.php.net/package/Config&quot;&gt;PEAR Config&lt;/a&gt;, &lt;a href=&quot;http://solarphp.com/class/Solar/config()&quot;&gt;Solar_Config&lt;/a&gt;, you name it.  You can throw exceptions for attempting to access a setting that isn&#039;t there, or just return null if you wish, but no more PHP notices about unset variables or array keys.  Prevent changes to these settings except by actually modifying the configuration file.  Store your passwords in an encrypted form.  Place the actual configuration file &lt;em&gt;outside of the web root&lt;/em&gt;.  Make an instance of your configuration class available statically in a registry or by calling a static method.&lt;/p&gt;

&lt;p&gt;Event hooks should be managed by a class with methods to add or remove hooks.  Throw exceptions for an invalid event name or an unusable callback reference.  Better yet: design a plugin API that implements the Listener or Observer pattern.  You don&#039;t want someone inserting an invalid hook that breaks an entire system.&lt;/p&gt;

&lt;p&gt;So long story short: use PHP 5&#039;s static properties or static methods to make available system settings and stop using kludgy globals.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Fri, 02 Nov 2007 17:14:45 +0000</pubDate>
    <guid isPermaLink="false">https://devweblog.org/archives/10-guid.html</guid>
    <category>no more php4</category>
<category>php</category>
<category>refactoring</category>
<creativeCommons:license>http://creativecommons.org/licenses/by-sa/3.0/</creativeCommons:license>
</item>
<item>
    <title>Xdebug and PHPUnit Flies</title>
    <link>https://devweblog.org/archives/9-Xdebug-and-PHPUnit-Flies.html</link>
            <category>PHP</category>
    
    <comments>https://devweblog.org/archives/9-Xdebug-and-PHPUnit-Flies.html#comments</comments>
    <wfw:comment>https://devweblog.org/wfwcomment.php?cid=9</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>https://devweblog.org/rss.php?version=2.0&amp;type=comments&amp;cid=9</wfw:commentRss>
    

    <author>nospam@example.com (Double Compile)</author>
    <content:encoded>
    &lt;p&gt;Taking note of blog entries from &lt;a href=&quot;http://derickrethans.nl/&quot;&gt;Derek Rethans&lt;/a&gt; and &lt;a href=&quot;http://sebastian-bergmann.de/&quot;&gt;Sebastian Bergmann&lt;/a&gt; about &lt;a href=&quot;http://sebastian-bergmann.de/archives/709-Profiling-and-Optimizing-PHPUnit.html&quot; title=&quot;Profiling and Optimizing PHPUnit&quot;&gt;speed improvements to PHPUnit&#039;s&lt;/a&gt; use of &lt;a title=&quot;Xdebug 2.0.1&quot; href=&quot;http://derickrethans.nl/xdebug_201.php&quot;&gt;Xdebug for code coverage analysis&lt;/a&gt;, I obtained the latest copies of each.&lt;/p&gt;
&lt;p&gt;Running the full code coverage report for all &lt;a href=&quot;http://xyster.devweblog.org&quot;&gt;Xyster&lt;/a&gt; tests used to take about 15 minutes on my modest hardware.  The new versions of these libraries reduced that time to under 2 minutes.  I was floored.&lt;/p&gt;&lt;p&gt;Well done, boys!  Anyone running or using either library should &lt;i&gt;definitely&lt;/i&gt; upgrade.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Tue, 23 Oct 2007 17:19:57 +0000</pubDate>
    <guid isPermaLink="false">https://devweblog.org/archives/9-guid.html</guid>
    <category>code coverage</category>
<category>php</category>
<category>phpunit</category>
<category>releases</category>
<category>unit testing</category>
<category>xdebug</category>
<creativeCommons:license>http://creativecommons.org/licenses/by-sa/3.0/</creativeCommons:license>
</item>
<item>
    <title>No More PHP 4, Pt. 1: Support more than one RDBMS</title>
    <link>https://devweblog.org/archives/6-No-More-PHP-4,-Pt.-1-Support-more-than-one-RDBMS.html</link>
            <category>PHP</category>
    
    <comments>https://devweblog.org/archives/6-No-More-PHP-4,-Pt.-1-Support-more-than-one-RDBMS.html#comments</comments>
    <wfw:comment>https://devweblog.org/wfwcomment.php?cid=6</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>https://devweblog.org/rss.php?version=2.0&amp;type=comments&amp;cid=6</wfw:commentRss>
    

    <author>nospam@example.com (Double Compile)</author>
    <content:encoded>
    &lt;p&gt;I applaud the efforts of the &lt;a href=&quot;http://gophp5.org/&quot;&gt;GoPHP5&lt;/a&gt; campaign.  They&#039;re getting commitments from lots of projects to adhere to minimum requirements of PHP 5.2; PHP 4 is end-of-life very soon.  In addition to offering projects the chance to refactor and improve their application design, PHP 5 offers many things PHP 4 just doesn&#039;t.  This series of posts will deal with things projects can get their fingers into that will benefit everyone.&lt;/p&gt;
&lt;p&gt;The first: you have no excuse to support only one database.&lt;/p&gt;
&lt;p&gt;PHP and MySQL for many years have gone together like bread-and-butter.  Some applications still only solidly support MySQL.  Nothing is inherently wrong with MySQL (shush, trolls), but not everyone can or will run it.  I can&#039;t imagine many of these PHP applications are using super-proprietary MySQL features that can&#039;t be done with other systems.&lt;/p&gt;
&lt;p&gt;Use an abstraction layer for your data access.  &lt;a href=&quot;http://www.php.net/manual/en/ref.pdo.php&quot;&gt;PDO&lt;/a&gt; is a fantastic addition to PHP; it&#039;s been stable and in the core distribution for a good two years.  If you have the extensions for each system, PDO can out-of-the-box support MySQL, Sqlite, PostgreSQL, MS SQL Server, Oracle, and recently DB2.  In the Zend Framework, &lt;a href=&quot;http://framework.zend.com/manual/en/zend.db.html&quot;&gt;Zend_Db&lt;/a&gt; is a great tool as well.  It&#039;s fast, well-thought-out, has many convenient features, and provides some more abstraction than PDO does.  For instance, listing all the tables in a database, describing a table, and performing limit/offset queries.&lt;/p&gt;
&lt;p&gt;All that&#039;s left to you the application developer is writing the SQL for creating your tables in each database system.  As far as I&#039;m concerned (Yes, and my opinion matters), you should support the &amp;quot;Big 4&amp;quot; (MySQL, PostgreSQL, MS SQL, Oracle) out of the gate; these have the widest install base.&lt;/p&gt;
&lt;p&gt;Lastly, since you&#039;re going to the trouble of using such a data access layer, make sure you take advantage of value binding.  Binding your values to placeholders in the SQL statement greatly reduces the risk of SQL injections.  It also lets the DB worry about how to escape the value.&lt;/p&gt;
&lt;p&gt;So stop being database system elitists.  You&#039;ll have a wider and happier user install base if your system supports a few databases.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Sat, 13 Oct 2007 15:53:00 +0000</pubDate>
    <guid isPermaLink="false">https://devweblog.org/archives/6-guid.html</guid>
    <category>abstraction layers</category>
<category>databases</category>
<category>gophp5</category>
<category>no more php4</category>
<category>php</category>
<creativeCommons:license>http://creativecommons.org/licenses/by-sa/3.0/</creativeCommons:license>
</item>

</channel>
</rss>