<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>david rasch -- technology. business. life. &#187; PHP</title>
	<atom:link href="http://www.davidrasch.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.davidrasch.com</link>
	<description></description>
	<lastBuildDate>Fri, 21 May 2010 02:58:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Gallery 2.2&#8211;Multisite and Multiroot</title>
		<link>http://www.davidrasch.com/2007/09/24/gallery-22-multisite-and-multiroot/</link>
		<comments>http://www.davidrasch.com/2007/09/24/gallery-22-multisite-and-multiroot/#comments</comments>
		<pubDate>Tue, 25 Sep 2007 02:48:54 +0000</pubDate>
		<dc:creator>drasch</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[dachshund]]></category>
		<category><![CDATA[drna]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[photos]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.davidrasch.com/2007/09/24/gallery-22-multisite-and-multiroot/</guid>
		<description><![CDATA[<p>Recently I tried to use the Gallery Multiroot module/plugin to setup a new site based upon an existing Album in our gallery.  Since we started sorting albums chronologically, we wanted to sort out the Dachshund photos separately.  To do this, I used the Multiroot feature.  Unfortunately, I couldn&#8217;t get this to work as <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.davidrasch.com/2007/09/24/gallery-22-multisite-and-multiroot/">Gallery 2.2&#8211;Multisite and Multiroot</a></span>]]></description>
			<content:encoded><![CDATA[<p>Recently I tried to use the <a href="http://gallery.raschnet.com">Gallery</a> Multiroot module/plugin to setup a new site based upon an existing Album in our gallery.  Since we started sorting albums chronologically, we wanted to sort out the Dachshund photos separately.  To do this, I used the <a href="http://codex.gallery2.org/Gallery2:Modules:multiroot">Multiroot</a> feature.  Unfortunately, I couldn&#8217;t get this to work as I&#8217;m already using the Multisite plugin to host several Galleries off of my web server.  The magic touch was to use the following file, the first line is key and had to be added to make things work in the Multisite configuration.  </p>
<pre class="brush: php;">
define('GALLERY_CONFIG_DIR', &quot;/var/virtualwww/gallery.raschnet.com&quot;);  //I had to add this line

require('/usr/local/share/gallery2/embed.php');
$ret = GalleryEmbed::init(
    array('embedUri' =&gt; '/',
          'g2Uri' =&gt; 'http://gallery.raschnet.com/',
          'apiVersion' =&gt; array(1, 2)
    ));

if ($ret) {
    print '&lt;body&gt;' . $ret-&gt;getAsHtml() . '&lt;/body&gt;';
    return;
}

$gallery-&gt;setConfig('login', true);
$gallery-&gt;setConfig('defaultAlbumId', 28426);
$gallery-&gt;setConfig('breadcrumbRootId', 28426);

GalleryMain();
</pre>
<p>Now live: <a href="http://drna.raschnet.com">DRNA Gallery</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidrasch.com/2007/09/24/gallery-22-multisite-and-multiroot/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Blog Tweaks</title>
		<link>http://www.davidrasch.com/2007/09/22/blog-tweaks/</link>
		<comments>http://www.davidrasch.com/2007/09/22/blog-tweaks/#comments</comments>
		<pubDate>Sun, 23 Sep 2007 02:38:28 +0000</pubDate>
		<dc:creator>drasch</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[delicious]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[tags]]></category>
		<category><![CDATA[widget]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.davidrasch.com/2007/09/22/blog-tweaks/</guid>
		<description><![CDATA[<p>Made some tweaks to the blog:</p>

using tags instead of categories
google ads
amazon wishlist
I learned lots more about widgets
integration with <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.davidrasch.com/2007/09/22/blog-tweaks/">Blog Tweaks</a></span>]]></description>
			<content:encoded><![CDATA[<p>Made some tweaks to the blog:</p>
<ul>
<li>using tags instead of categories</li>
<li>google ads</li>
<li>amazon wishlist</li>
<li>I learned lots more about widgets</li>
<li>integration with my delicious</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.davidrasch.com/2007/09/22/blog-tweaks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP on the Backend (part 2)</title>
		<link>http://www.davidrasch.com/2007/05/08/php-on-the-backend-part-2/</link>
		<comments>http://www.davidrasch.com/2007/05/08/php-on-the-backend-part-2/#comments</comments>
		<pubDate>Tue, 08 May 2007 23:34:02 +0000</pubDate>
		<dc:creator>drasch</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[daemon]]></category>

		<guid isPermaLink="false">http://www.davidrasch.com/2007/05/08/php-on-the-backend-part-2/</guid>
		<description><![CDATA[<p>To run the class I posted yesterday, I typically use a class called DaemonRunner.  This class sets up for proper signal handling, and &#8216;executes&#8217; the class extended from Daemon.</p>

declare(ticks=1);

class DaemonRunner {
    public static function exec($className) {
        $argv = $_SERVER['argv'];
       <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.davidrasch.com/2007/05/08/php-on-the-backend-part-2/">PHP on the Backend (part 2)</a></span>]]></description>
			<content:encoded><![CDATA[<p>To run the class I <a href="http://www.davidrasch.com/2007/05/07/php-on-the-backend/">posted yesterday</a>, I typically use a class called <em>DaemonRunner</em>.  This class sets up for proper signal handling, and &#8216;executes&#8217; the class extended from Daemon.</p>
<pre>
declare(ticks=1);

class DaemonRunner {
    public static function exec($className) {
        $argv = $_SERVER['argv'];
        $daemon = new $className($argv);
        $daemon->init();
        while (!$daemon->isDone()) {
            $daemon->run();
        }
        $daemon->shutdown();
    }
}
</pre>
<p>The first statement is a PHPism.  This allows PHP to check for signals every 1 <em>tick</em>.  A tick is simply a low-level PHP interpreter step.  The way I&#8217;ve setup my daemon and signal handling by default, the PHP will finish its current iteration and then quit when receiving a signal.  This ensures that the database, and whatever background stuff aren&#8217;t left in inconsistent states.  As with anything, you&#8217;re free to modify, extend, or otherwise alter this behavior.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidrasch.com/2007/05/08/php-on-the-backend-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP on the Backend</title>
		<link>http://www.davidrasch.com/2007/05/07/php-on-the-backend/</link>
		<comments>http://www.davidrasch.com/2007/05/07/php-on-the-backend/#comments</comments>
		<pubDate>Tue, 08 May 2007 00:55:39 +0000</pubDate>
		<dc:creator>drasch</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[daemon]]></category>

		<guid isPermaLink="false">http://www.davidrasch.com/2007/05/07/php-on-the-backend/</guid>
		<description><![CDATA[<p>PHP (or any language for that matter) can just as easily be used as a daemon as on the web.  This can be especially useful when solving problems that can&#8217;t &#8220;complete&#8221; in less than 500 ms which one shoots for on the web.   As you write an application to handle things such as <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.davidrasch.com/2007/05/07/php-on-the-backend/">PHP on the Backend</a></span>]]></description>
			<content:encoded><![CDATA[<p>PHP (or any language for that matter) can just as easily be used as a daemon as on the web.  This can be especially useful when solving problems that can&#8217;t &#8220;complete&#8221; in less than 500 ms which one shoots for on the web.   As you write an application to handle things such as those mentioned below, be sensitive to the processing, disk space, and time needed to process these requests in planning how to handle these.  As an example jobs of a small size might be handled inline by the code that handles the form submission, but for larger jobs it queues them for background processing.  </p>
<p>great for background/async processing of:</p>
<ul>
<li>photos</li>
<li>movies</li>
<li>reports</li>
<li>imports of data</li>
</ul>
<p>advantages: </p>
<ul>
<li>use the same codebase as your app</li>
<li>use the same expertise on your team of programmers</li>
</ul>
<p>challenges:</p>
<ul>
<li>signals</li>
<li>one thread</li>
<li>memory (this will have to be a whole separate article)</li>
<li>starting and stopping</li>
</ul>
<p>A typical Daemon class I use:</p>
<pre>
abstract class Daemon {
    protected $done = false;

    public function __construct($argv) {
    }
    public function init() {
        pnctl_signal(SIGTERM, array($this, "onSignal"));
        pnctl_signal(SIGINT, array($this, "onSignal"));

    }
    abstract public function run();
    public function shutdown() {}
    public function isDone() {
        return $this->done;
    }
    public onSignal($signal){
        switch ($signal) {
             case SIGTERM:
             case SIGINT:
                $this->done = true;
                 break;
             default:
                 // handle all other signals
        }
    }
}</pre>
<p>As you can see, we&#8217;ve started to tackle some of the challenges here.  The idea is to handle signals, specifically I usually care about SIGTERM (default when using &#8216;kill&#8217; on *nix) and SIGINT (from pressing Ctrl-C).  Both will cause the program to exit gracefully.</p>
<p>I&#8217;ll be posting the class I use to run Daemon&#8217;s tomorrow.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidrasch.com/2007/05/07/php-on-the-backend/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>TriPUG and MySQL Talk on Memcache and PHP</title>
		<link>http://www.davidrasch.com/2007/05/03/tripug-and-mysql-post-on-memcache-and-php/</link>
		<comments>http://www.davidrasch.com/2007/05/03/tripug-and-mysql-post-on-memcache-and-php/#comments</comments>
		<pubDate>Fri, 04 May 2007 01:03:45 +0000</pubDate>
		<dc:creator>drasch</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Systems]]></category>
		<category><![CDATA[Talks]]></category>
		<category><![CDATA[memcache]]></category>

		<guid isPermaLink="false">http://www.davidrasch.com/2007/05/03/tripug-and-mysql-post-on-memcache-and-php/</guid>
		<description><![CDATA[<p>Memcache is an extension written by Danga for simple Key/Value pair caching for use with your favorite programming language.  In this talk I demonstrate how to install, integrate, and leverage Memcache in PHP (using MySQL for a database).  I build a sample application, demonstrate less than desirable performance and finally, return performance with a <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.davidrasch.com/2007/05/03/tripug-and-mysql-post-on-memcache-and-php/">TriPUG and MySQL Talk on Memcache and PHP</a></span>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.danga.com/memcached/">Memcache</a> is an extension written by Danga for simple Key/Value pair caching for use with your favorite programming language.  In this <a href="http://www.davidrasch.com/talks/2007-05-memcache/">talk</a> I demonstrate how to install, integrate, and leverage Memcache in PHP (using MySQL for a database).  I build a sample application, demonstrate less than desirable performance and finally, return performance with a 100x improvement.</p>
<p>The whole talk and its supporting files can also be <a href="http://www.davidrasch.com/talks/2007-05-memcache/2007-05-memcache.zip">downloaded</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidrasch.com/2007/05/03/tripug-and-mysql-post-on-memcache-and-php/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>ditched the Zend Framework</title>
		<link>http://www.davidrasch.com/2007/03/19/ditched-the-zend-framework/</link>
		<comments>http://www.davidrasch.com/2007/03/19/ditched-the-zend-framework/#comments</comments>
		<pubDate>Tue, 20 Mar 2007 01:41:00 +0000</pubDate>
		<dc:creator>drasch</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[sadface]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://www.davidrasch.com/2007/03/19/ditched-the-zend-framework/</guid>
		<description><![CDATA[<p>I&#8217;ve ditched the Zend Framework on a project.  In it&#8217;s place, Symfony has allowed me to recreate all the work with the Zend Framework over several months in a matter of 4 hours.  </p>
<p>The Zend Framework proved to be:</p>

too piecemeal
incomplete &#8211; arguably this is represented by the version number; but this applied to both <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.davidrasch.com/2007/03/19/ditched-the-zend-framework/">ditched the Zend Framework</a></span>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve ditched the Zend Framework on a project.  In it&#8217;s place, Symfony has allowed me to recreate all the work with the Zend Framework over several months in a matter of 4 hours.  </p>
<p>The Zend Framework proved to be:</p>
<ul>
<li>too piecemeal</li>
<li>incomplete &#8211; arguably this is represented by the version number; but this applied to both individual components being incomplete and the lack of a complete offering for a whole application</li>
<li>in flux &#8211; changing each time we updated such that it was difficult to get the newer components without breaking lots of our code</li>
<li>too rigid &#8211; we found it far too rigid and requiring much code diving, without much direction, to redirect some of the logic especially in the Controller framework </li>
</ul>
<p>All in all, Symfony has proved very easy to use, and has many facets and components I haven&#8217;t yet even been able to take advantage of.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidrasch.com/2007/03/19/ditched-the-zend-framework/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Zend Framework and PDO_MYSQL</title>
		<link>http://www.davidrasch.com/2007/02/06/zend-framework-and-pdo_mysql/</link>
		<comments>http://www.davidrasch.com/2007/02/06/zend-framework-and-pdo_mysql/#comments</comments>
		<pubDate>Wed, 07 Feb 2007 03:35:58 +0000</pubDate>
		<dc:creator>drasch</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://www.davidrasch.com/2007/02/06/zend-framework-and-pdo_mysql/</guid>
		<description><![CDATA[<p>I&#8217;ve been working with the Zend Framework a bit and in working with MySQL through PDO_MYSQL.  I&#8217;ve run into a few problems trying to use parameters of queries.</p>
<p>I&#8217;ve narrowed the issue down to PDO itself and not the Zend Framework.</p>
<p>
$dbh = new PDO("mysql:host=localhost;dbname=db","user","pw");
$query = "insert into silo_test_data (record_id, fieldname, value)
      <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.davidrasch.com/2007/02/06/zend-framework-and-pdo_mysql/">Zend Framework and PDO_MYSQL</a></span>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working with the Zend Framework a bit and in working with MySQL through PDO_MYSQL.  I&#8217;ve run into a few problems trying to use parameters of queries.</p>
<p>I&#8217;ve narrowed the issue down to PDO itself and not the Zend Framework.</p>
<p><code><br />
$dbh = new PDO("mysql:host=localhost;dbname=db","user","pw");<br />
$query = "insert into silo_test_data (record_id, fieldname, value)<br />
               values (3,'stufftest', :value )";<br />
$handle = $dbh->prepare($query);<br />
$handle->execute(array(":value" => 'crap'));<br />
$dbh = null;<br />
</code></p>
<p>The value gets inserted into the database as an empty string, or sometimes some low-value bytes.  I&#8217;ve managed to work around this temporarily thanks to some help from <a href="http://netevil.org/node.php?nid=795&#038;SC=1">this post</a>.  By setting PDO to emulate prepared statements, everything seems to work okay.</p>
<p><code><br />
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);<br />
</code></p>
<p>The problem is, the Zend framework encapsulates the actual db connection and connects lazily.  So, for now I&#8217;m running a query and then set the parameter on the encapsulated connection object.</p>
<p><code><br />
$db_connect = array( 'host' => $config->db->hostname,<br />
    'username' => $config->db->username,<br />
    'password' => $config->db->password,<br />
    'dbname' => $config->db->database );<br />
$db = Zend_Db::factory('PDO_MYSQL', $db_connect);<br />
$db->query('select 1');//HACK HACK HACK HACK to initiate connection.  Can't I make this a plugin?  or extend the class?<br />
$db->getConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);<br />
Zend::register('db',$db);<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidrasch.com/2007/02/06/zend-framework-and-pdo_mysql/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>don&#8217;t eat paste (learning PHP part iii)</title>
		<link>http://www.davidrasch.com/2006/10/16/dont-eat-paste-learning-php-part-iii/</link>
		<comments>http://www.davidrasch.com/2006/10/16/dont-eat-paste-learning-php-part-iii/#comments</comments>
		<pubDate>Tue, 17 Oct 2006 03:26:44 +0000</pubDate>
		<dc:creator>drasch</dc:creator>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[learning php]]></category>
		<category><![CDATA[php books]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.davidrasch.com/2006/10/16/dont-eat-paste-learning-php-part-iii/</guid>
		<description><![CDATA[<p>Hi, David. This is an interesting approach, but I think it’s a solution to a slightly different problem than teaching someone PHP. Instead, it’s a solution to teaching someone the basics of building a web app and you just happen to use PHP to teach those concepts. A perfectly worthwhile and desirable goal, but different.
&#8230;
</p>
<p>David Sklar</p>
<p>I <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.davidrasch.com/2006/10/16/dont-eat-paste-learning-php-part-iii/">don&#8217;t eat paste (learning PHP part iii)</a></span>]]></description>
			<content:encoded><![CDATA[<blockquote><p>Hi, David. This is an interesting approach, but I think it’s a solution to a slightly different problem than teaching someone PHP. Instead, it’s a solution to teaching someone the basics of building a web app and you just happen to use PHP to teach those concepts. A perfectly worthwhile and desirable goal, but different.<br />
&#8230;
</p></blockquote>
<p><a href="http://www.davidrasch.com/2006/10/12/learning-sheltered-php-sans-bad-habits/#comment-333"><em>David Sklar</em></a></p>
<p>I agree and disagree with some of the points Sklar (sorry, two David&#8217;s makes this confusing) goes on to make.  If I may paraphrase, Sklar is raising a point which competes with that raised by <a href="http://benramsey.com/?p=166">Ben</a> in our initial discussion.  My initial suggestion in the discussion with Ben indicated that books should start by teaching PHP on the command-line and slowly build up to constructing a very lightweight MVC framework and example application.   One of Ben&#8217;s chief, and valid, concerns equated selling books about PHP with convincing readers or page-flippers that the book would teach them to build web pages in the first few chapters.  Or that individuals might be turned off if they weren&#8217;t creating XSS attacks willy-nilly by chapter 3.  I think the counter to this that Sklar raised is that by hiding the framework you turn off the people who don&#8217;t feel they&#8217;re really getting their feet wet with PHP.  They feel that by using your framework they aren&#8217;t learning the &#8216;real guts&#8217; of the language.  </p>
<p>This clearly relates directly to some of the arguments Sklar makes that other languages face this challenge as well, but PHP perhaps more so than others.  PHP digs its own hole here because unlike a .NET, Java, or a ColdFusion, PHP has built its name on easy to learn and get going.  You can pay $4.99/month and get a server running PHP in 10 minutes.  Writing an application in any of these other platforms can take orders of magnitude longer to setup, there&#8217;s an expectation of barrier to entry for learning, and often you have to buy pieces of it like an IDE.  Sklar indicates that it&#8217;s important to strike the balance between &#8220;a way to do things&#8221; and &#8220;the way to do things&#8221;. </p>
<p>The dilemma lies in choosing whether I ask the reader to take on faith that the framework underlying the first half of the book isn&#8217;t worth delving into right now, but is worth understanding later and either using the quick framework or garner enough knowledge of the principles to build your own.  Or, do I go back to my original plan of introducing PHP on the command-line as we built up a small framework and graduate up to a web page far later in the book.  </p>
<p>I have full confidence that either approach might work.  I know universities teach Physics both with and without calculus to which I&#8217;m sure the physics professors initially said &#8220;you can&#8217;t teach physics without calculus, it&#8217;s heresy!&#8221;  But, this day in age there&#8217;s only one physics.   I know my economics professor told me she didn&#8217;t like math, but she managed to teach a great class about economics concepts by moving lines back and forth on graphs.  </p>
<p>[tags]learning php, programming, computer science, php, php books[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidrasch.com/2006/10/16/dont-eat-paste-learning-php-part-iii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning PHP sans bad habits</title>
		<link>http://www.davidrasch.com/2006/10/12/learning-sheltered-php-sans-bad-habits/</link>
		<comments>http://www.davidrasch.com/2006/10/12/learning-sheltered-php-sans-bad-habits/#comments</comments>
		<pubDate>Fri, 13 Oct 2006 02:53:15 +0000</pubDate>
		<dc:creator>drasch</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[teaching]]></category>

		<guid isPermaLink="false">http://www.davidrasch.com/2006/10/12/learning-sheltered-php-sans-bad-habits/</guid>
		<description><![CDATA[<p>I&#8217;ve received some fatalistic responses to my last installment related to what I see as problems with PHP teachings.  In particular, I fear we teach people to write applications in ways that are reckless to the fact that these individuals likely read no more than 1-2 PHP books and move on to start writing their <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.davidrasch.com/2006/10/12/learning-sheltered-php-sans-bad-habits/">Learning PHP sans bad habits</a></span>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve received some fatalistic responses to my <a href="http://www.davidrasch.com/2006/09/30/php-appalachia/">last installment</a> related to what I see as problems with PHP teachings.  In particular, I fear we teach people to write applications in ways that are reckless to the fact that these individuals likely read no more than 1-2 PHP books and move on to start writing their application. </p>
<p>Now I&#8217;ll present some solutions I propose to the challenges of teaching PHP without encouraging bad habits from the beginning.  </p>
<p><strong>Chapter 1:</strong> Intro to PHP syntax using the commnd-line<br />
<strong>Chapter 2:</strong> Make your first dynamic web page using our small framework (hello world)<br />
   The framework handles: data escaping input and output, proper sql injection protection, and data/presentation separation.  The student needn&#8217;t understand all of this yet, but will be explained.<br />
<strong>Chapter 3:</strong> Variables &#038; Arrays<br />
<strong>Chapter 4:</strong> Conditionals, Loops &#038; Functions<br />
<strong>Chapter 5:</strong> Classes<br />
<strong>Chapter 6:</strong> Sending/Receiving data on the web.<br />
<strong>Chapter 7:</strong> How to create additional pages in the framework<br />
<strong>Chapter 8:</strong> Creating forms<br />
<strong>Chapter 9:</strong> Dissect the framework input/output, presentation and database aspects<br />
<strong>Chapter 10:</strong> Show how failing to do these things is insecure<br />
<strong>Chapter 11:</strong> Create additional views/flow using OO framework<br />
<strong>Chapter 12:</strong> Create a simple application with 3-4 views</p>
<p>This describes the mostly the PHP aspects of a book.  This book could easily use SQLite and save the MySQL for another book where it can be properly introduced.  It could also include some MySQL education to increase its marketability.  The framework itself sounds like a big undertaking, but in fact it can be kept extremely simple as governed by the examples put forth herein.  In addition, the frameworks simplicity will allow it to be dissected later in the book for the education of the reader.  Finally, when someone finishes the book (or the worst risk with current books if they <strong>don&#8217;t</strong> finish it, they&#8217;ll still have the right ideas and not go willy-nilly writing an application using $_GET and $_POST without thinking twice.  </p>
<p>[tags]teaching, learning, php[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidrasch.com/2006/10/12/learning-sheltered-php-sans-bad-habits/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>PHP Appalachia</title>
		<link>http://www.davidrasch.com/2006/09/30/php-appalachia/</link>
		<comments>http://www.davidrasch.com/2006/09/30/php-appalachia/#comments</comments>
		<pubDate>Sun, 01 Oct 2006 04:26:34 +0000</pubDate>
		<dc:creator>drasch</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://www.davidrasch.com/2006/09/30/php-appalachia/</guid>
		<description><![CDATA[<p> Brian and I went to PHP Appalachia this Wednesday and Thursday.  Different from a traditional conference, the Cherokee, NC KOA served as the main venue for PHP Appalachia.  The two of us stayed in a Kabin with a full bed and a set of bunks.  All of us hiked, chatted, and met <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.davidrasch.com/2006/09/30/php-appalachia/">PHP Appalachia</a></span>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/73037677@N00/256787532"><img width="255" height="191" align="right" src="http://static.flickr.com/90/256787532_029e960dd9.jpg?v=0" /></a> Brian and I went to <a href="http://www.phpappalachia.org">PHP Appalachia</a> this Wednesday and Thursday.  Different from a traditional conference, the Cherokee, NC KOA served as the main venue for PHP Appalachia.  The two of us stayed in a Kabin with a full bed and a set of bunks.  All of us hiked, chatted, and met with the other attendees until we left mid-day on Thursday.</p>
<p>We sat around the fire on Wednesday night chatting about PHP when Ben Ramsey and I entered an interesting discussion about PHP&#8217;s future and how to introduce newbies to PHP.</p>
<p>I&#8217;ll define the sterotype which serves as the premise for this discussion. Most books that introduce PHP, even those which rely on previous programming knowledge begin with an example like this:
<pre class="brush: php;">print &quot;hello world&quot;;</pre>
<p>   This example will be soon followed within the next 1-3 chapters (sometimes after, sometimes before introducing loops, conditions, and other basic language constructs of PHP) by an example like this:
<pre class="brush: php;">print $_GET['foo'];</pre>
<p>  In any/all books it&#8217;s far later in the book where Object-Oriented programming is covered.  In the coverage of creating forms, handling GET/POST/Cookies/Session there&#8217;s relatively little talk of security, escaping, or encodings.  </p>
<p>The long and short is that people learn PHP in a way that first teaches them to design web applications in a  poorly maintainable, insecure, and generally poor method.  With the advent frameworks like the Zend Framework and other MVC-based libraries there&#8217;s no need to teach bad habits that result in a bad name for PHP.  </p>
<p>[tags]php, books, rant[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidrasch.com/2006/09/30/php-appalachia/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
