Phprest\Application::registerController PHP Method

registerController() public method

public registerController ( string $class ) : void
$class string Namespaced class name
return void
    public function registerController($class)
    {
        $controller = new $class($this->container);
        $this->container->add($class, function () use($controller) {
            return $controller;
        });
    }

Usage Example

Example #1
0
 public function testRegisterController()
 {
     $this->app->registerController('\\Phprest\\Stub\\Controller\\Simple');
     $this->assertInstanceOf('\\Phprest\\Stub\\Controller\\Simple', $this->app->getContainer()->get('\\Phprest\\Stub\\Controller\\Simple'));
 }