Guys I am new in slim framework. Iam creating a controller class and read in documentation i have read when slim create controller object it passes ‘ContainerInterface’ as argument automatically. But I am facing this is exception.
Argument 1 passed to OurOwnNamespace\Controller\Test::__construct() must be an instance of Psr\Container\ContainerInterface, null given, called in /Applications/XAMPP/xamppfiles/htdocs/slim/vendor/slim/slim/Slim/CallableResolver.php on line 149
Here is my controller code:
<?php
namespace OurOwnNamespace\Controller;
use Psr\Container\ContainerInterface;
class Test
{
protected $con;
public function __construct(ContainerInterface $container)
{
$this->con=$container;
}
public function hello($request,$response,$args){
return $response;
}
}
Here is my route:
$app->get('/', Test::class . ':hello');