V
V
Valeron Sergeev2020-01-31 16:15:37
PHP
Valeron Sergeev, 2020-01-31 16:15:37

What is the correct way to instantiate Psr\Http\Message\ResponseInterface?

Good day, having difficulty with Psr\Http\Message\ResponseInterface
there is the following code

<?php
use Slim\Views\PhpRenderer;
use Psr\Http\Message\ResponseInterface;

error_reporting(E_ALL);
ini_set('display_errors',true);

define('H', $_SERVER['DOCUMENT_ROOT'].'/');

session_start();
ob_start();

require H . 'system/vendor/autoload.php';

try {

  require H .'system/common.php';

  $response = new ResponseInterface();

  $phpView = new PhpRenderer(H . 'app/templates/', ["title" => "My App"]);
  $phpView->setLayout("layout.php");
  $phpView->render($response, 'main.php', ["title" => "Hello - My App", "name" => "John"]);

} catch (Exception $e) {

  die ('Error ' . $e->getMessage());

}

Error Fatal error: Uncaught Error: Cannot instantiate interface Psr\Http\Message\ResponseInterface Previously did not work with Psr\Http\Message\ResponseInterface.
Can you tell me what I'm doing wrong or how to work with it correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shamanov, 2020-01-31
@fwlone

cannot create object from interface

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question