title: Routing Lib for PHP7
body: <p>I need to use a routing plugin for php and I decided to use nikic/FastRoute [<a href="https://github.com/nikic/FastRoute]" rel="nofollow">https://github.com/nikic/FastRoute]</a>. But, because of my limited knowledge to php, I still cannot use it successfully. </p>
  
  <p>Here is my code. </p>
  
  <pre><code>require_once 'FastRoute/src/functions.php';
  # create a stack of actions
  
  $dispatcher = FastRoute\simpleDispatcher(function(FastRoute\RouteCollector $r) {
      $r-&gt;addRoute('GET', '/', 'get_all_users_handler');
      // {id} must be a number (\d+)
      $r-&gt;addRoute('GET', '/contract-management', 'get_user_handler');
      // The /{title} suffix is optional
      $r-&gt;addRoute('GET', '/articles/{id:\d+}[/{title}]', 'get_article_handler');
  });
  
  // Fetch method and URI from somewhere
  $httpMethod = $_SERVER['REQUEST_METHOD'];
  $uri = $_SERVER['REQUEST_URI'];
  
  // Strip query string (?foo=bar) and decode URI
  if (false !== $pos = strpos($uri, '?')) {
      $uri = substr($uri, 0, $pos);
  }
  $uri = rawurldecode($uri);
  
  $routeInfo = $dispatcher-&gt;dispatch($httpMethod, $uri);
  switch ($routeInfo[0]) {
      case FastRoute\Dispatcher::NOT_FOUND:
          // ... 404 Not Found
          break;
      case FastRoute\Dispatcher::METHOD_NOT_ALLOWED:
          $allowedMethods = $routeInfo[1];
          // ... 405 Method Not Allowed
          break;
      case FastRoute\Dispatcher::FOUND:
          $handler = $routeInfo[1];
          $vars = $routeInfo[2];
          // ... call $handler with $vars
          break;
  }
  
  function get_user_handler(){
      print_r("here");
  }
  
  function get_article_handler(){
      print_r("article handler");
  }
  </code></pre>
  
  <p>I just changed require '/path/to/vendor/autoload.php'; to require_once 'FastRoute/src/functions.php'; from the example code. But the below error shown. </p>
  
  <p>Fatal error: Uncaught Error: Class 'FastRoute\RouteCollector' not found in C:\wamp\www\testproj\includes\FastRoute\src\functions.php:21 Stack trace: #0 C:\wamp\www\testproj\includes\routing.php(13): FastRoute\simpleDispatcher(Object(Closure)) #1 C:\wamp\www\testproj\index.php(9): require_once('C:\wamp\www\testp...') #2 {main} thrown in C:\wamp\www\testproj\includes\FastRoute\src\functions.php on line 21</p>
  
  <p>I think I did something wrong with setting up. But I still cannot find a better sample for the beginners. So, please point me where did I do wrong. Thanks in advance.</p>