title: How to avoid outside of request scope exception in silex application?
body: <p>After restructuring my silex1.2 application, I am now getting hit by:</p>
  
  <blockquote>
    <p>exception 'RuntimeException' with message 'Accessed request service
    outside of request scope. Try moving that call to a before handler or
    controller.' in
    ../vendor/silex/silex/src/Silex/Application.php:150</p>
  </blockquote>
  
  <p>I used to setup the appilcation's config this way:</p>
  
  <pre><code>$app = new Silex\Application();
  $app-&gt;register(new ServiceControllerServiceProvider());
  $app-&gt;register(new ConfigServiceProvider($configFile));
  $fileFinder = new \Symfony\Component\Finder\Finder();
  foreach ($fileFinder-&gt;in($configPath . 'country') as $file) {
     /* @var SplFileInfo $file */
      $app-&gt;register(new ConfigServiceProvider($file-&gt;getRealPath()));
  }
  </code></pre>
  
  <p>I now wanted to replace the <code>foreach</code> loop by injecting a specific value which I get from the user's request. So I wanted to access <code>$request-&gt;query-&gt;get('country')</code>; yet I cannot since <code>app['request']</code> is out of scope at that point.</p>
  
  <p>I don't understand the error message, as in:</p>
  
  <ul>
  <li>When and why are request objects out of scope in silex?</li>
  <li>How am I supposed to move the call before handler and controllers when it is the very first thing I do on setting up my application?</li>
  </ul>
  
  <p>Basically, I want to access request data early on on in order to get one value. How can I achieve that in order to bootstrap application accordingly?</p>