title: Running Zend Framework on PHP 5.1.6 - patch or fix for ksort()?
body: <p>I've built a ZF app using 1.10 for deployment on RHEL server in a corporate client, which has PHP 5.1.6. It won't run.</p>
  
  <p>I googled and now realise it's the version of PHP. I didn't realise ZF had a minimum requirement for PHP 5.2.4, and calls to HeadLink seem to be causing fatal error "Call to undefined method Zend_View_Helper_Placeholder_Container::ksort()":</p>
  
  <pre><code>PHP Fatal error:  Call to undefined method Zend_View_Helper_Placeholder_Container::ksort() in /library/ Zend/View/Helper/HeadLink.php on line 321
  </code></pre>
  
  <p>The client won't upgrade their PHP; I don't want to rewrite the app without ZF, and I'd rather not downgrade ZF to a grossly earlier version.</p>
  
  <p>Is there some patch I can use to add ksort() to ZF 1.10 to get around this? There may be other problems, but this is where I'm stuck right now.</p>
  
  <p>Any advice welcome</p>
  
  <p>Many thanks</p>
  
  <p>Ian</p>
  
  <p>EDIT: As I say in a comment below, I expect many people have hit this before and will keep on doing so as RHEL5 will be a standard in corporate environments for a good time to come. I was hoping for a link to an existing solution rather having to devise one from scratch.</p>
  
  <p>UPDATE: I used the patch linked to in the accepted answer and it fixed the problem for me. </p>
  
  <p>This is adding the following public method to Zend/View/Helper/Placeholder/Container/Abstract.php</p>
  
  <pre><code>    /** 
   * Sort the array by key 
   * 
   * @return array 
   */ 
  public function ksort() 
  { 
      $items = $this-&gt;getArrayCopy(); 
      return ksort($items); 
  }
  </code></pre>
  
  <p>There was one remaining issue; a PHP notice caused by a string conversion in Zend_View_Helper_Doctype. Comparing this function to similar ones above and below, this seems to be an error in the library</p>
  
  <pre><code>public function isHtml5() {
      return (stristr($this-&gt;doctype(), '&lt;!DOCTYPE html&gt;') ? true : false);
  }
  </code></pre>
  
  <p>Changed to:</p>
  
  <pre><code>public function isHtml5() {
      return (stristr($this-&gt;getDoctype(), '&lt;!DOCTYPE html&gt;') ? true : false);
  }
  </code></pre>
  
  <p>Patching the library itself was the last thing I would normally do, but in this case it got me out of a spot. We'll make sure the patch is versioned in the repo and documented obviously for future developers.</p>