title: PHP front controller library with support for unit testing
body: <p>I am looking for a (small) library that helps me cleanly implement a <a href="http://www.martinfowler.com/eaaCatalog/frontController.html" rel="nofollow noreferrer">front controller</a> for my <a href="http://semanticscuttle.sourceforge.net" rel="nofollow noreferrer">pet project</a> and dispatches requests to single controller classes. The front controller/dispatcher and controller classes need to be fully unittestable without sending HTTP requests.</p>
  
  <h2>Requirements</h2>
  
  <ul>
  <li><a href="http://groups.google.com/group/php-standards/web/psr-0-final-proposal" rel="nofollow noreferrer">PSR-0</a> compatible</li>
  <li>installable via its own <a href="http://pear.php.net/manual/en/channels.whatarethey.php" rel="nofollow noreferrer">PEAR channel</a></li>
  <li>support for unit testing:
  
  <ul>
  <li>checking if the correct HTTP headers are sent</li>
  <li>catches output to allow inspection in unit tests</li>
  <li>perferably PHPUnit helper methods to help inspecting the output (for different output types, i.e. HTML, XML, JSON)</li>
  <li>allows setting of incoming HTTP headers, GET and POST parameters and cookies without actually doing HTTP requests</li>
  </ul></li>
  <li>needs to be usable standalone - without the db abstraction, templating and so that the fat frameworks all provide</li>
  </ul>
  
  <h2>Background</h2>
  
  <p>SemanticScuttle, the application that is bound to get proper "C" support, is an existing, working application. The library needs to blend in it and needs to work with the existing structure and classes. I won't rewrite it to match a framework's specific required directory layout.</p>
  
  <p>The application already has unittests, but based on HTTP requests which make them slow. Also, the current old way of having several dozens of <code>.php</code> files in the <code>www</code> directory isn't the most managable solution, which is why proper controller classes need to be introduced. All in all, there will be about 20-30 controllers.</p>
  
  <h2>Previous experience</h2>
  
  <p>In general, I was pretty happy with Zend Framework for some previous projects but it has several drawbacks:</p>
  
  <ul>
  <li>not pear-installable, so I cannot use it as dependency in my pear-installble applications</li>
  <li>only available as one fat download, so I manually need to extract the required bits from it - for each single ZF update.</li>
  <li>while unit test support exists for ZF controllers, it's lacking some advanced utility functionality like assertions for json, HTTP status code and content type checks.</li>
  </ul>
  
  <p>While these points seem to be nit-picking, they are important for me. If I have to implement them myself, I do not need to use an external libary but write my own.</p>
  
  <h2>What I don't want</h2>
  
  <p>StackOverflow has a million "what's the best PHP framework" questions (<a href="https://stackoverflow.com/q/4143169/282601">1</a>, <a href="https://stackoverflow.com/q/75882/282601">2</a>, <a href="https://stackoverflow.com/q/199023/282601">3</a>, <a href="https://stackoverflow.com/q/914057/282601">4</a>, <a href="https://stackoverflow.com/q/678284/282601">5</a>), but I'm not looking for those but for a <strong>specific</strong> library that helps with controllers. If it's part of a modular framework, fine.</p>
  
  <p>I also know the <a href="http://www.phpframeworks.com/" rel="nofollow noreferrer">PHP framework comparison website</a>, but it doesn't help answer my question since my requirements are not listed there.</p>
  
  <p>And I know that I can build this all on my own and invent another microframework. But why? There are so many of them already, and one just has to have all that I need.</p>
  
  <h2>Related questions</h2>
  
  <ul>
  <li><a href="https://stackoverflow.com/q/694929/282601">What's your 'no framework' PHP framework?</a></li>
  <li><a href="https://stackoverflow.com/q/417774/282601">How do you convert a page-based PHP application to MVC?</a></li>
  </ul>