title: How does MVC routing work?
body: <p>So I've started studying MVC (real MVC, not framework MVC) a bit more in-depth, and I'm attempting to develop a small framework. I'm working by reading other frameworks such as Symphony and Zend, seeing how they do their job, and attempt to implement it myself.</p>
  
  <p>The place where I got stuck was the URL routing system:</p>
  
  <pre><code>&lt;?php
  namespace Application\Common;
  
  class RouteBuilder {
  
      public function create($name, $parameters) {
          $route           = new Route($name);
          $route-&gt;resource = array_keys($parameters)[0];
          $route-&gt;defaults = $parameters["defaults"];
          $notation        = $parameters["notation"];
          $notation = preg_replace("/\[(.*)\]/", "(:?$1)?", $notation);
          foreach ($parameters["conditions"] as $param =&gt; $condition) {
              $notation = \str_replace($param, $condition, $notation);
          }
  
          $notation = preg_replace("/:([a-z]+)/i", "(?P&lt;$1&gt;[^/.,;?\n]+)", $notation);
  
          //@TODO: Continue pattern replacement!!
      }
  }
  /* How a single entry looks like
   * "main": {
      "notation": "/:action",
      "defaults": {
          "resource"  :   "Authentication",
      },
      "conditions":   {
          ":action"   :   "(login)|(register)"
      }
  },
  
   */
  </code></pre>
  
  <p>I just can't get my head wrapped around it properly. What is the application workflow from here?</p>
  
  <p>The pattern is generated, probably a <code>Route</code> object to be kept under the <code>Request</code> object or something, then what? How does it work?</p>
  
  <blockquote>
    <p><strong>P.S.</strong> Looking for a real, well explained answer here. I really want to understand the subject. I would appreciate if someone took the time to write a real elaborate answer.</p>
  </blockquote>