title: How to work with subdirectory controllers in CodeIgniter 4?
body: <p>I need help with using sub directory controllers in CodeIgniter 4.</p>
  
  <p>I just can't make it work for some reason.</p>
  
  <p>This is the URL for example: <code>www.example.com/admin/dashboard</code></p>
  
  <p>In the controllers folder, I created a folder named <code>Admin</code>, and a file named <code>Dashboard.php</code>.</p>
  
  <p>I used this code in <code>Dashboard.php</code>:</p>
  
  <pre><code>namespace App\Controllers;
  
  class Dashboard extends BaseController
  {
      public function index()
      {
  
      }
  }
  </code></pre>
  
  <p>I tried changing the class name to <code>AdminDashboard</code>, <code>Admin_Dashboard</code>, pretty much every logical name but every time I get a 404 error, saying:</p>
  
  <blockquote>
    <p>Controller or its method is not found:
    App\Controllers\Admin\Dashboard::index</p>
  </blockquote>
  
  <p>I know the file itself gets loaded successfully, but I think I don't declare the classname correctly and it keeps throwing me those 404 errors.</p>
  
  <p>The documentation of CI4 isn't providing any information about what the classname should be called unfortunately...</p>
  
  <hr>
  
  <h2>UPDATE #1</h2>
  
  <p>I managed to make it work by changing few things:</p>
  
  <pre><code>namespace App\Controllers\Admin;
  use CodeIgniter\Controller;
  
  class Dashboard extends Controller
  {
      public function index()
      {
  
      }
  }
  </code></pre>
  
  <p>But now it won't extend the <code>BaseController</code> which has some core functions that I built for my app.</p>
  
  <p>Any ideas to how to make it extend <code>BaseController</code>?</p>
  
  <p>I must admit that I don't have much knowledge about namespacing yet, so that might be the reason for my mistakes.</p>