title: CakePHP Error: Class App\Controller\AuthComponent not found
body: <p>I'm working in CakePHP 3.2 and writing an admin panel where only admin can login.</p>
  
  <p>There is a separate table <code>admins</code> to store admin credentials. There is <code>users</code> table also which is used for users to register/login from main application.</p>
  
  <p>I have to use <code>admins</code> table to login in admin panel.</p>
  
  <p>What I have done is.</p>
  
  <pre><code>&lt;?php
  namespace App\Controller;
  
  use Cake\Controller\Controller;
  use Cake\Event\Event;
  
  
  class AppController extends Controller
  {
  
      public function initialize()
      {
          parent::initialize();
  
          $this-&gt;loadComponent('RequestHandler');
          $this-&gt;loadComponent('Flash');
          $this-&gt;loadComponent('Auth', [
            'loginAction' =&gt; [
              'controller' =&gt; 'Admins',
              'action' =&gt; 'login',
              'plugin' =&gt; 'Admins'
            ],
            'loginRedirect' =&gt; [
              'controller' =&gt; 'ServiceRequests',
              'action' =&gt; 'index'
            ],
            'logoutRedirect' =&gt; [
              'controller' =&gt; 'Admins',
              'action' =&gt; 'login'
            ],
            'authenticate' =&gt; [
              'Form' =&gt; [
                'userModel' =&gt; 'Admin',
                'fields' =&gt; [
                  'username' =&gt; 'email',
                  'password' =&gt; 'password'
                ]
              ]
            ]
          ]);
      }
  
      public function beforeRender(Event $event)
      {
          if (!array_key_exists('_serialize', $this-&gt;viewVars) &amp;&amp;
              in_array($this-&gt;response-&gt;type(), ['application/json', 'application/xml'])
          ) {
              $this-&gt;set('_serialize', true);
          }
      }
  }
  </code></pre>
  
  <p><code>AdminsController.php</code></p>
  
  <pre><code>&lt;?php
  namespace App\Controller;
  
  use App\Controller\AppController;
  use Cake\Event\Event;
  use App\Controller\AuthComponent;
  
  /**
   * Admins Controller
   *
   * @property \App\Model\Table\AdminsTable $Admins
   */
  class AdminsController extends AppController
  {
        public function beforeFilter(Event $event)
        {
            parent::beforeFilter($event);
            $this-&gt;Auth-&gt;allow('add');
            // Pass settings in using 'all'
            $this-&gt;Auth-&gt;config('authenticate', [
              AuthComponent::ALL =&gt; ['userModel' =&gt; 'Members'],
                'Basic',
                'Form'
            ]);
        }
  
      public function login()
      {
          if ($this-&gt;request-&gt;is('post')) {
              $user = $this-&gt;Auth-&gt;identify();
              if ($user) {
                  $this-&gt;Auth-&gt;setUser($user);
                  return $this-&gt;redirect($this-&gt;Auth-&gt;redirectUrl());
              }
              $this-&gt;Flash-&gt;error(__('Invalid username or password, try again'));
          }
      }
  
      public function logout()
      {
          return $this-&gt;redirect($this-&gt;Auth-&gt;logout());
      }
  }
  </code></pre>
  
  <p>But this is not working. and gives <code>Error: Class App\Controller\AuthComponent' not found</code></p>
  
  <p>Also I want to restrict access to all controllers and actions without login. Thats why there is no <code>$this-&gt;Auth-&gt;allow()</code> in <code>AppsController.php</code></p>