title: Call to a member function checkAccess() on a non-object yii2
body: <p>I am following <a href="http://www.yiiframework.com/doc-2.0/guide-security-authorization.html#access-check" rel="nofollow">http://www.yiiframework.com/doc-2.0/guide-security-authorization.html#access-check</a> to implement RBAC. When I am using this</p>
  
  <pre><code>if (\Yii::$app-&gt;user-&gt;can('createPost')) {
      // create post
  }
  </code></pre>
  
  <p>in SiteController 's actionLogin() function </p>
  
  <p>I am getting an error <code>Call to a member function checkAccess() on a non-object yii2</code></p>
  
  <p>Can you find out the way to sort it out ?
  My RBAC config is </p>
  
  <pre><code>'authManager' =&gt; [
          'class' =&gt; 'yii\rbac\PhpManager',
          'itemFile' =&gt; '@app/rbac/items.php', 
          'assignmentFile' =&gt; '@app/rbac/assignments.php',  
          'ruleFile' =&gt; '@app/rbac/rules.php',  
  
          ],
  </code></pre>
  
  <p>I am trying to use it in site controllers's</p>
  
  <pre><code>public function actionLogin()
      {
          if (!\Yii::$app-&gt;user-&gt;isGuest) {
              return $this-&gt;goHome();
          }
  
          $model = new LoginForm();
          if ($model-&gt;load(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $model-&gt;login()) {
  
  
  
          print_r(\Yii::$app-&gt;user-&gt;can('createPost'));exit;
  }}
  </code></pre>