title: Laravel: Getting Route Parameters in Route::group() Closure
body: <p>I have an app running on Laravel 4.2, and I am trying to implement a somewhat complex routing mechanism. I have a route group set up using:</p>
  
  <pre><code>Route::group(['domain' =&gt; '{wildcard}.example.com'], $closure);
  </code></pre>
  
  <p>I need to be able to check the $wildcard parameter <em>in the closure for the group</em> -- meaning before the request gets passed to the controller (I need to defined <code>Route::get()</code> and <code>Route::post()</code> depending on the subdomain).</p>
  
  <p>An example of what I'd like to do is as follows:</p>
  
  <pre><code>Route::group(['domain' =&gt; '{wildcard}.example.com', function ($wildcard) {
          if ( $wildcard == 'subdomain1' ) {
              Route::get('route1', 'Subdomain1Controller@getRoute1');
              Route::get('route2', 'Subdomain1Controller@getRoute2');
          } else if ( $wildcard == 'subdomain2' ) {
              Route::get('route1', 'Subdomain2Controller@getRoute1');
              Route::get('route2', 'Subdomain2Controller@getRoute2');
          }
      }
  );
  </code></pre>
  
  <p>Of course, the above does not work. The only parameter passed into a <code>Route::group()</code> closure is an instance of <code>Router</code>, not the parameters defined in the array. However, there <em>must</em> be a way to access those parameters -- I know for a fact that I've done it before, I just don't remember how (and can't find the solution anywhere online).</p>
  
  <p>I know I can always use PHP's lower-level methods to retrieve the URL, <code>explode()</code> it, and check the subdomain that way. But I've done it before using Laravel's methods, and if possible, I'd prefer to do it that way (to keep things clean and consistent)</p>
  
  <p>Does anyone else know the solution? Thanks in advance!</p>