<?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/"
	xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>Pointless Rants &#187; PHP</title>
	<atom:link href="http://www.pointlessrants.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pointlessrants.com</link>
	<description>Rants that are usually about technology</description>
	<lastBuildDate>Thu, 09 Sep 2010 11:41:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<!-- podcast_generator="podPress/8.8" - maintenance_release="8.8.6.3" -->
	<copyright>Copyright &#xA9; 2010 Pointless Rants </copyright>
	<managingEditor>daspecster@gmail.com (Thomas Schultz)</managingEditor>
	<webMaster>daspecster@gmail.com (Thomas Schultz)</webMaster>
	<category>Technology</category>
	<ttl>1440</ttl>
	<image>
		<url>http://www.pointlessrants.com/wp-content/plugins/podpress/images/podcast_logo_144.jpg</url>
		<title>Pointless Rants &#187; PHP</title>
		<link>http://www.pointlessrants.com</link>
		<width>144</width>
		<height>144</height>
	</image>
	<itunes:subtitle>Pointless Rants about technology and everyday happenings</itunes:subtitle>
	<itunes:summary>Rants that are usually about technology</itunes:summary>
	<itunes:keywords>rants, technology, computers, programming, network, windows, mac, linux</itunes:keywords>
	<itunes:category text="Technology" />
	<itunes:category text="Technology">
		<itunes:category text="Tech News" />
	</itunes:category>
	<itunes:category text="News &#38; Politics" />
	<itunes:author>Thomas Schultz</itunes:author>
	<itunes:owner>
		<itunes:name>Thomas Schultz</itunes:name>
		<itunes:email>daspecster@gmail.com</itunes:email>
	</itunes:owner>
	<itunes:block>no</itunes:block>
	<itunes:explicit>no</itunes:explicit>
	<itunes:image href="http://www.pointlessrants.com/wp-content/plugins/podpress/images/podcast_logo_300.jpg" />
		<item>
		<title>PHP5-CLI versus Python CLI</title>
		<link>http://www.pointlessrants.com/2009/08/php5-cli-versus-python-cli/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=php5-cli-versus-python-cli</link>
		<comments>http://www.pointlessrants.com/2009/08/php5-cli-versus-python-cli/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 16:58:12 +0000</pubDate>
		<dc:creator>Tom Schultz</dc:creator>
				<category><![CDATA[Blog Post]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Errors]]></category>
		<category><![CDATA[Interface]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.daspecster.com/?p=534</guid>
		<description><![CDATA[Python versus PHP type error example]]></description>
			<content:encoded><![CDATA[<p>I just thought this was kind of interesting.   Out of the box CLI comparison of PHP and Python type errors <img src='http://www.pointlessrants.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<h3>Python</h3>
<pre lang="python">&gt;&gt;&gt; test = 123
&gt;&gt;&gt; test2 = "ewfwef"
&gt;&gt;&gt; test / test2
Traceback (most recent call last):
File "&lt;stdin&gt;", line 1, in &lt;module&gt;
<strong>TypeError: unsupported operand type(s) for /: 'int' and 'str'</strong></pre>
<h3>PHP</h3>
<pre lang="php">$test = 123;
$test2 = "werwe";
echo $test/$test2;

<strong>Warning: Division by zero in Command line code on line 1</strong></pre>
<p>It&#8217;s nice that python tells you what is really wrong here, you can&#8217;t divide an integer by a string! PHP on the other hand implies that $test2 is equivalent to 0.<br />
It should be noted that python is doing a trace and PHP is not. Doing a trace on the error in PHP would give more information but since PHP is very weak with types, you would probably have to notice the error on your own.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://www.pointlessrants.com/2009/02/python-scripting-within-a-python-script/" rel="bookmark" class="crp_title">Python Scripting within a Python Script</a></li><li><a href="http://www.pointlessrants.com/2009/02/symfony-sfmodelgeneratorclassphp-line-321-error/" rel="bookmark" class="crp_title">Symfony sfModelGenerator.class.php line 321 error</a></li><li><a href="http://www.pointlessrants.com/2009/02/opengl-in-python/" rel="bookmark" class="crp_title"># OpenGL in Python</a></li><li><a href="http://www.pointlessrants.com/2009/07/python-easter-eggs/" rel="bookmark" class="crp_title"># Python Easter Eggs</a></li><li><a href="http://www.pointlessrants.com/2009/10/setting-up-for-python-development-in-ubuntu/" rel="bookmark" class="crp_title">Setting up for Python development in Ubuntu</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.pointlessrants.com/2009/08/php5-cli-versus-python-cli/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP Contextual Navigation in Symfony</title>
		<link>http://www.pointlessrants.com/2009/03/php-contextual-navigation-in-symfony/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=php-contextual-navigation-in-symfony</link>
		<comments>http://www.pointlessrants.com/2009/03/php-contextual-navigation-in-symfony/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 10:35:29 +0000</pubDate>
		<dc:creator>Steve Oxley</dc:creator>
				<category><![CDATA[Blog Post]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[contextual navigation]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[menu]]></category>
		<category><![CDATA[navigation]]></category>

		<guid isPermaLink="false">http://www.daspecster.com/?p=329</guid>
		<description><![CDATA[The concept is that I created a component to handle displaying the navigation menu and included the component in the layout.  All the component has to do is remove the current page from a list of pages that are retrieved from the global configuration file and display them as a list. ]]></description>
			<content:encoded><![CDATA[<p>I am currently working on a project using <a href="http://www.symfony-project.org">symfony</a> and got to a point where I wanted to add a contextual navigation menu.  In other words, I wanted to have a menu that would show a list of pages, but not show the current page.  After considering using slots, components, and component slots, I decided on a solution that I like.  Read on to find out what it is.<span id="more-329"></span></p>
<p>The concept is that I created a component to handle displaying the navigation menu and included the component in the layout.  All the component has to do is remove the current page from a list of pages that are retrieved from the global configuration file and display them as a list.  To do this, I simply created a component &#8211; you can look <a href="http://www.symfony-project.org/book/1_2/07-Inside-the-View-Layer">here</a> to find out how to do that in detail.</p>
<p>What it meant for me is that I created a module in my application called &#8220;navigation&#8221; (I made a folder called navigation in the modules folder) and then in the <code>navigation/actions</code> folder I created my components file:  <code>components.class.php</code>.  This is where the logic for your component goes.  Then, I created a file (partial) called <code>_navMenu.php</code> in <code>navigation/templates</code> (we&#8217;ll get to why you call it that in a second) &#8211; this is the template that is displayed for the component.</p>
<h3>The component logic</h3>
<p>The logic for the component was as follows:</p>
<pre><code>
// apps/app_name/modules/navigation/actions/components.class.php
class navigationComponents extends sfComponents
{
  /**
   * Executes the building of the navigation menu.
   */
  public function executeNavMenu()
  {
    $route = sfContext::getInstance()-&gt;getRouting()-&gt;getCurrentRouteName();
    $this-&gt;pages = sfConfig::get('app_navpages');
    unset($this-&gt;pages[$route]);
  }
}
</code></pre>
<p>Basically, you&#8217;re <code>components.class.php</code> file is what includes all of the components &#8211; since mine only includes one component (<code>navMenu</code>) I probably could have just had the class inherit from <code>sfComponent</code>, but I think that this may come in handy later if I ever want to add another component.  Now, the name of the method (<code>executeNavMenu</code>) is important &#8211; it determines what partial in the <code>templates</code> folder will be displayed (<code>_navMenu.php</code> &#8211; I told you we&#8217;d get to that) and it determines the name that will be used to include the component in the layout (or whatever view you may want to include the component in).  My particular component is very simple &#8211; it gets the current route (as defined in <code>routing.yml</code>) and gets a list of my possible navigation menu pages as defined in my <code>app.yml</code> file:</p>
<pre><code>
// apps/app_name/config/app.yml - app_name is not the actual name...
all:
  .array:
    navpages:
      homepage: { name: 'Home', route: '@homepage'}
      person_index: { name: 'Manage Users', route: '@person_index' }
</code></pre>
<p>Once I have these two bits of information, I take the item for the current route out of the list with the line <code>unset($this-&gt;pages[$route])</code>.  In my <code>routing.yml</code> file, my homepage route is defined as the following:</p>
<pre><code>
homepage:
  url:   /
  param: { module: home, action: index }
</code></pre>
<p>So, for example, if I am at my homepage (http://example.com/), <code>$route</code> will contain the string &#8216;homepage&#8217; and the item with the key &#8216;homepage&#8217; will be removed from the list.  Then, the variable <code>$pages</code> will be available in my template (partial) to be displayed.</p>
<h3>The Component View</h3>
<p>The code for the <code>_navMenu.php</code> partial is even more simple:</p>
<pre><code>
&lt;div id="navigation"&gt;
  &lt;ul id="nav"&gt;
    &lt;?php foreach ($pages as $page): ?&gt;
      &lt;li&gt;&lt;?php echo link_to($page['name'], $page['route']); ?&gt;&lt;/li&gt;
    &lt;?php endforeach; ?&gt;
  &lt;/ul&gt;
&lt;/div&gt;
</code>
</pre>
<p>In fact, it&#8217;s so simple that I don&#8217;t even think it needs explanation.</p>
<h3>Including the Component in the Layout</h3>
<p>Now all that remains is to include the component in the layout.  That can be accomplished with this one-liner:</p>
<pre><code>
&lt;?php include_component('navigation', 'navMenu'); ?&gt;
</code></pre>
<p>The first argument is the module in which to find the component and the second argument is the name (which I mentioned earlier) of the component itself (the name of the method minus the <code>execute</code> on the front).</p>
<p>As you can see, all of the individual pieces are very simple, and when you put them all together, you get a nice, logical way of building a contextual navigation menu.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://www.pointlessrants.com/2009/10/setting-up-for-python-development-in-ubuntu/" rel="bookmark" class="crp_title">Setting up for Python development in Ubuntu</a></li><li><a href="http://www.pointlessrants.com/2009/03/functionmethod-decorators/" rel="bookmark" class="crp_title"># Function/Method Decorators</a></li><li><a href="http://www.pointlessrants.com/2009/06/override-decorator/" rel="bookmark" class="crp_title"># Override decorator</a></li><li><a href="http://www.pointlessrants.com/2009/02/iterators/" rel="bookmark" class="crp_title"># Iterators</a></li><li><a href="http://www.pointlessrants.com/2009/03/getattr-deserves-some-respect/" rel="bookmark" class="crp_title"># __getattr__ Deserves Some Respect</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.pointlessrants.com/2009/03/php-contextual-navigation-in-symfony/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Symfony sfModelGenerator.class.php line 321 error</title>
		<link>http://www.pointlessrants.com/2009/02/symfony-sfmodelgeneratorclassphp-line-321-error/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=symfony-sfmodelgeneratorclassphp-line-321-error</link>
		<comments>http://www.pointlessrants.com/2009/02/symfony-sfmodelgeneratorclassphp-line-321-error/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 05:32:22 +0000</pubDate>
		<dc:creator>Tom Schultz</dc:creator>
				<category><![CDATA[Blog Post]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.daspecster.com/?p=161</guid>
		<description><![CDATA[How I fixed the "Fatal error: Class 'PersonForm' not found in /var/www/cam/trunk/lib/generator/sfModelGenerator.class.php on line 321" error that I received in Symfony. ]]></description>
			<content:encoded><![CDATA[<p>Well I&#8217;ve been playing with <a href="http://www.symfony-project.org">Symfony</a> and I started building modules today from the <a href="http://www.symfony-project.org/jobeet/1_2/Propel/en/03">Jobeet day 3 tutorial</a> and I ran into an issue.   The Symfony Project is basically a framework in which you can build PHP web applications which I&#8217;ve been using for a school project.</p>
<p>I&#8217;m not sure if I missed a step of if this is a system specific problem but basically I went to run the &#8220;symfony propel:build-module&#8221; command to genereate my module files and I got this error.</p>
<blockquote><p>Fatal error: Class &#8216;PersonForm&#8217; not found in /var/www/cam/trunk/lib/generator/sfModelGenerator.class.php on line 321</p></blockquote>
<p><span id="more-161"></span></p>
<p>The &#8220;PersonForm&#8221; class was, as the error indicated, no where to be found.  It turned out that I needed to run the command &#8220;<strong>symfony cc</strong>&#8221; which clears the symfony cache of files.   I also had to run the command &#8220;<strong>symfony propel:build-forms</strong>&#8220;  in order to get symfony to build my modules.</p>
<p>So to re-cap</p>
<ol>
<li>Run $ php symfony cc</li>
<li>Run $ php symfony propel:build-forms</li>
<li>Run $ php symfony build:module  (Params)</li>
</ol>
<p>Once I did those steps the build:module step worked perfectly and I was able to view the skeleton application at my dev.php/person url.</p>
<p>Symfony seems to be very very powerful and I&#8217;m excited to learn how to develope applications with it.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://www.pointlessrants.com/2009/02/development-vs-production-environments/" rel="bookmark" class="crp_title">Development Environments vs. Production Environments</a></li><li><a href="http://www.pointlessrants.com/2009/03/php-contextual-navigation-in-symfony/" rel="bookmark" class="crp_title">PHP Contextual Navigation in Symfony</a></li><li><a href="http://www.pointlessrants.com/2009/08/php5-cli-versus-python-cli/" rel="bookmark" class="crp_title">PHP5-CLI versus Python CLI</a></li><li><a href="http://www.pointlessrants.com/2010/01/linux-commands-that-make-me-happy/" rel="bookmark" class="crp_title">Linux commands that make me happy</a></li><li><a href="http://www.pointlessrants.com/2009/05/windows-7-rc-%e2%80%93-it%e2%80%99s-here-for-a-year/" rel="bookmark" class="crp_title">Windows 7 RC – It’s Here for a Year!</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.pointlessrants.com/2009/02/symfony-sfmodelgeneratorclassphp-line-321-error/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Development Environments vs. Production Environments</title>
		<link>http://www.pointlessrants.com/2009/02/development-vs-production-environments/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=development-vs-production-environments</link>
		<comments>http://www.pointlessrants.com/2009/02/development-vs-production-environments/#comments</comments>
		<pubDate>Sun, 01 Feb 2009 17:00:35 +0000</pubDate>
		<dc:creator>Steve Oxley</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[built-in functions]]></category>
		<category><![CDATA[environments]]></category>
		<category><![CDATA[objects]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.daspecster.com/?p=85</guid>
		<description><![CDATA[I had no idea what to do since I’m a symfony noob and the only thing that I thought was really different between production and development was that one cached and the other didn’t...]]></description>
			<content:encoded><![CDATA[<p>I like the idea of having two separate environments for my website.  That way I do not have to worry about remembering to turn off the profiler (if I&#8217;m using a profiler) or making sure that I do not mess up the database while messing around with test data etcetera.  There is also no question that <a href="http://symfony-project.org">Symfony</a> executes the Development/Test/Production environment philosophy very well.  However, there is also no question that, when one runs into a bug that only shows up in one environment and not in the other, it can be very difficult to squash, indeed.</p>
<p><span id="more-85"></span></p>
<p>This is what happened to me today.  I have been working on the <a href="http://www.symfony-project.org/jobeet/1_2/Propel/en/">Jobeet</a> tutorial and, on day 16, they asked me to implement an XML/JSON/YAML API module.  Of course, since it&#8217;s a tutorial, they give you all the code and I was mostly just copy-pasting, but once I started poking around after completing part of the chapter, I noticed that the production environment only displayed one record while the development environment displayed (correctly) about thirty records.  I knew this wasn&#8217;t right.  My first reaction was to try clearing the cache &#8211; no luck.  Now I had no idea what to do since I&#8217;m a symfony noob and the only thing that I thought was really different between production and development was that one cached and the other didn&#8217;t (and the databases could be different if you wanted to set them that way, but I hadn&#8217;t &#8211; it&#8217;s just a tutorial, after all).</p>
<p>Well, to make a long story an amazing amount shorter, I went digging and found that a URL that was being generated in a loop to be used as an array key was always the same  (but only when debugging was disabled).  After some more digging, I found that the reason that it was always the same is that the method used to generate the URL was supposed to take an array as an argument and I was passing it an object instead (because the tutorial told me to).  Now here is the interesting part:  the reason this did not work was, indeed, because of caching.  It just so happens that the symfony hashing function for its URL cache uses the PHP function array_merge().  Now, I haven&#8217;t looked into this in depth, but I guess when trying to merge an array and an object this function isn&#8217;t the best.  However, when there is no caching enabled, the way symfony generates the URL is by using a custom function called mergeArrays:</p>
<pre><code>
protected function mergeArrays($arr1, $arr2)
{
  foreach ($arr2 as $key =&gt; $value)
  {
    $arr1[$key] = $value;
  }

  return $arr1;
}
</code></pre>
<p>Now, if <code>$arr1</code> were an object this wouldn&#8217;t work since you can&#8217;t access members of an object with the <code>[]</code> operators, but, since my object was being passed into <code>$arr2</code>, it worked fine.</p>
<p>The one thing I cannot decide now is if this blog post is a warning against the dangers of development vs. production environments, rewriting functions that are included in the language, dynamic languages in general, or something else I haven&#8217;t thought of.  I do know I learned several things from the experience, though.  First, it&#8217;s almost always my code that&#8217;s wrong &#8211; not the framework.  Second, just because it works in development doesn&#8217;t mean it will work in production.  And third, validate your input &#8211; if you&#8217;re expecting an array, make sure it&#8217;s an array and not some random object.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://www.pointlessrants.com/2009/02/symfony-sfmodelgeneratorclassphp-line-321-error/" rel="bookmark" class="crp_title">Symfony sfModelGenerator.class.php line 321 error</a></li><li><a href="http://www.pointlessrants.com/2009/03/php-contextual-navigation-in-symfony/" rel="bookmark" class="crp_title">PHP Contextual Navigation in Symfony</a></li><li><a href="http://www.pointlessrants.com/2009/03/functionmethod-decorators/" rel="bookmark" class="crp_title"># Function/Method Decorators</a></li><li><a href="http://www.pointlessrants.com/2009/02/iterators/" rel="bookmark" class="crp_title"># Iterators</a></li><li><a href="http://www.pointlessrants.com/2009/03/getattr-deserves-some-respect/" rel="bookmark" class="crp_title"># __getattr__ Deserves Some Respect</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.pointlessrants.com/2009/02/development-vs-production-environments/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
