<?php

//базовый класс контроллера
class AppController{

  protected $request ;
  protected $response;
  protected $args;
  protected $container;

  public function __construct($request, $response, $container ,$args = null){
    $this->request = $request;
    $this->response = $response;
    $this->args = $args;
    $this->container = $container;

 }

}

//класс контроллера
class TestController extends AppController {


  public function __construct($request, $response, $container ,$args = null){

    parent::__construct($request, $response, $container ,$args);

  }

  public function testRedirect(){
	//проблема в том что у меня отлично работает к примеру
	//все отрисовывается как нужно
	$this->container->view->render( $this->response, 'test.php', $data );
    // но не работает редирект
    return $this->response->withRedirect('/', 301);

	// в классе 	TestController объект $response доступен как $this->response и он доступен,
	// через var_dump печатается, но метод withRedirect не работает

  }

}

$app->get('/test',function($request, $response){
	
//так я вызываю нужный контроллер и его метод
//this  в данном контексте - это контейнер который опеределяется в самом $app - слим

return (new Controllers\TestController($request, $response, $this))->testRedirect();

});


