title: Using PSR4-Autoloading via Composer vs spl_autoload_register
body: <p>We're building a new Slim application and we want to use PSR4-Autoloading with namespaces in our code.</p>
  
  <p>We found two ways to do that, via Composer i.e.:</p>
  
  <pre><code>"autoload": {
      "psr-4": {
          "App\\Controller\\": "app/controllers",
          "App\\Middleware\\": "app/middleware",
          "App\\Model\\": "app/models"     
      }
  },
  </code></pre>
  
  <p>Or via <code>spl_autoload_register</code> i.e.:</p>
  
  <pre><code>spl_autoload_register(function ($class_name) {
  
    $filename = __DIR__ . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $class_name) . '.php';
    require $filename;
  
  });
  </code></pre>
  
  <p>What determines which method we should go with?</p>