title: Laravel 5.3 API Versioning
body: <p>I am trying to get api versioning in place for an API I am working on, I found this <a href="https://laracasts.com/discuss/channels/general-discussion/api-version-control-in-header/replies/27732" rel="nofollow noreferrer">post</a> that explained how to do it using middleware and replacing a string in the route itself.  Basically specifying routes like this.</p>
  
  <pre><code>Route::group(['middleware' =&gt; ['api-version']], function() {
    Route::get('/endoint', ['uses' =&gt; '{api-namespace}\EndpointController@endpoint']);
  });
  </code></pre>
  
  <p>However, when I attempt this I get the following error</p>
  
  <pre><code>Class App\Http\Controllers\{api-namespace}\EndpointController does not exist
  </code></pre>
  
  <p>It would appear that the container is verifying the existence of route controller files prior to running the middleware which does the replacing.  I have added the middleware to the <code>$routeMiddleware</code> in the Http Kernel file.</p>
  
  <p>How can I accomplish this before it checks for the existence of the file?</p>
  
  <p>I thought about adding this to the applications global middleware but I do not want this to run on web only on api calls</p>