title: Found a mistake in the PHP Master Write Cutting-Edge Code?
body: <p>I am reading SitePoint's book <em>PHP Master Write Cutting-Edge Code</em>; on page 119 (Chapter 3, APIs) the authors say:</p>
  
  <blockquote>
    <p>For the example URL <a href="http://example.com/events" rel="nofollow">http://example.com/events</a>, the value of $controller_name becomes EventController and, since it’s a GET request, the $action_name is GETAction().</p>
  </blockquote>
  
  <p>The code is: </p>
  
  <pre><code>// initialize the request object and store the requested URL
  $request = new Request();
  $request-&gt;url_elements = array();
  if(isset($_SERVER['PATH_INFO'])) {
    $request-&gt;url_elements = explode('/', $_SERVER['PATH_INFO']);
  }
  // figure out the verb and grab the incoming data
  $request-&gt;verb = $_SERVER['REQUEST_METHOD'];
  switch($request-&gt;verb) {
    case 'GET':
      $request-&gt;parameters = $_GET;
      break;
    case 'POST':
    case 'PUT':
      $request-&gt;parameters = json_decode(file_get_contents➥ ('php://input'), 1);
      break;
    case 'DELETE':
    default:
      // we won't set any parameters in these cases
      $request-&gt;parameters = array();
  }
  
  // route the request
  if($request-&gt;url_elements) {
  $controller_name = ucfirst($request-&gt;url_elements[1]) .➥ 'Controller';
    if(class_exists($controller_name)) {
      $controller = new $controller_name();
      $action_name = ucfirst($request-&gt;verb) . "Action";
      $response = $controller-&gt;$action_name($request);
    } else {
      header('HTTP/1.0 400 Bad Request');
      $response = "Unknown Request for " . $request-&gt;url_elements[1];
    }
  } else {
    header('HTTP/1.0 400 Bad Request');
    $response = "Unknown Request";
  }
  </code></pre>
  
  <p>They use a <code>RewriteRule</code> of the Apache mod_rewrite module in an .htaccess file so that every request where the requested resource doesn't exist (not a file and not a dir) passes through an <em>index.php</em> script located at the document root of the server:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
      RewriteEngine On
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php/$1 [L]
  &lt;/IfModule&gt; 
  </code></pre>
  
  <p>So the request to <a href="http://example.com/events" rel="nofollow">http://example.com/events</a> is passed to <code>example.com/index.php/events</code> with <code>/events</code> as PATH_INFO. </p>
  
  <p>Not that I want to look finicky, but shouldn't the <code>EventController</code> be an <code>EventsController</code> because they split the PATH_INFO var and use the <code>$request-&gt;url_elements[1]</code> which will be <em>events</em> and not <em>event</em>? </p>