title: Silex security access outside request
body: <p>I'm trying to access the user token of my silex app outside of a request in order to manage includes depending on the logged in user. Since it's not working I broke down my script to be like this:</p>
  <pre><code>// .. I have registered the app and some other providers before this ...
  
  // Register the firewall
  $app-&gt;register(new Silex\Provider\SecurityServiceProvider());
  $app-&gt;register(new Silex\Provider\RememberMeServiceProvider());
  
  $app['security.firewalls'] = array(
      'login' =&gt; array(
          'pattern' =&gt; '^/login$',
      ),
      'secured' =&gt; array(
          'pattern' =&gt; '^.*$',
          'security' =&gt; true,
          'form' =&gt; array(
              'login_path' =&gt; '/login',
              'check_path' =&gt; '/login_check'
          ),
          'logout' =&gt; array(
              'logout_path' =&gt; '/logout',
              'invalidate_session' =&gt; true
          ),
          'users' =&gt; array(
              // raw password is foo
              'admin' =&gt; array('ROLE_ADMIN', '5FZ2Z8QIkA7UTZ4BYkoC+GsReLf569mSKDsfods6LYQ8t+a8EW9oaircfMpmaLbPBh4FOBiiFyLfuZmTSUwzZg=='),
          )
      )
  );
  
  // Boot the application to access security features
  $app-&gt;boot();
  
  // Get the token
  $token = $app['security']-&gt;getToken();
  var_dump($token);
  
  // ... Here comes the route definition ...
  
  $app-&gt;run();
  </code></pre>
  <p>The application is running and when I'm not logged in the token is NULL, what is right. But if I'm logged in the token is also NULL as long I access it outside the request. If I access it inside the request it is set. Silex documentation says:</p>
  <blockquote>
  <p>The security features are only available after the Application has been booted. So, if you want to use it outside of the handling of a request, don't forget to call boot() first:</p>
  <p>$app-&gt;boot();</p>
  </blockquote>
  <p>I thought this way I can access the token outside the request, but it's not working. Am I doing something wrong or didn't I get the documentation right?</p>