title: Slim controller issue : must be an instance of ContainerInterface, instance of Slim\\Container given
body: <p>I am trying to use controller in Slim however keep getting the error </p>
  
  <p>PHP Catchable fatal error:  Argument 1 passed to<br>
  TopPageController::__construct() must be an instance of ContainerInterface,<br>
  instance of Slim\Container given</p>
  
  <p>My index.php</p>
  
  <pre><code>&lt;?php
  use \Psr\Http\Message\ServerRequestInterface as Request;
  use \Psr\Http\Message\ResponseInterface as Response;
  
  require '../vendor/autoload.php';
  require 'settings.php';
  
  spl_autoload_register(function ($classname) {
      require ("../classes/" . $classname . ".php");
  });
  
  $app = new \Slim\App(["settings" =&gt; $config]);
  $app-&gt;get('/', function (Request $request, Response $response) {
      $response-&gt;getBody()-&gt;write("Welcome");
      return $response;
  });
  $app-&gt;get('/method1', '\TopPageController:method1');
  $app-&gt;run();
  ?&gt;
  </code></pre>
  
  <p>My TopPageController.php</p>
  
  <pre><code>&lt;?php
  class TopPageController {
     protected $ci;
     //Constructor
     public function __construct(ContainerInterface $ci) {
         $this-&gt;ci = $ci;
     }
  
     public function method1($request, $response, $args) {
          //your code
          //to access items in the container... $this-&gt;ci-&gt;get('');
          $response-&gt;getBody()-&gt;write("Welcome1");
          return $response;
     }
  
     public function method2($request, $response, $args) {
          //your code
          //to access items in the container... $this-&gt;ci-&gt;get('');
          $response-&gt;getBody()-&gt;write("Welcome2");
          return $response;
     }
  
     public function method3($request, $response, $args) {
          //your code
          //to access items in the container... $this-&gt;ci-&gt;get('');
          $response-&gt;getBody()-&gt;write("Welcome3");
          return $response;
     }
  }
  ?&gt;
  </code></pre>
  
  <p>Thanks. I am using Slim 3.</p>