First time seeing slim code, was given this app to work on, got this error when I finished setting up
Fatal error: Uncaught TypeError: Argument 1 passed to Slim\App::__construct() must be an instance of Psr\Http\Message\ResponseFactoryInterface, array given, called in C:\wamp64\www\KOKOFP API\index.php on line 19 and defined in C:\wamp64\www\KOKOFP API\vendor\slim\slim\Slim\App.php:61 Stack trace: #0 C:\wamp64\www\KOKOFP API\index.php(19): Slim\App->__construct(Array) #1 {main} thrown in C:\wamp64\www\KOKOFP API\vendor\slim\slim\Slim\App.php on line 61
index.php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
use \Interop\Container\ContainerInterface as ContainerInterface;
use Spearhead\Middleware\Logging as PersonalLogging;
use Spearhead\Middleware\Authentication;
session_start();
require 'vendor/autoload.php';
$settings = require __DIR__ . '/src/Spearhead/settings.php';
$app = new \Slim\App($settings);
$app->add(new PersonalLogging());
$app->add(function ($req, $res, $next) {
$response = $next($req, $res);
return $response
->withHeader('Access-Control-Allow-Credentials', 'true')
->withHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization')
->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
});
// Set up Dependencies
require __DIR__ . '/src/Spearhead/dependencies.php';
$app->get('/', function (Request $request, Response $response, array $args) {
$this->logger->addInfo($request->getMethod() . " -- " . $request->getUri());
return $this->renderer->render($response, 'index.phtml', ['data'=>[
'title' => 'Spearhead API',
'header_title' => 'SPEARHEAD API SEED'
]]);
});
$app->get('/docs', function (Request $request, Response $response, array $args) {
$this->logger->addInfo($request->getMethod() . " -- " . $request->getUri());
$swagger = \Swagger\scan(__DIR__ . '/src/Spearhead/');
header('Content-Type: application/json');
$arrray['swagger'] = $swagger;
$arrray['title'] = "Spearhead Documentation";
// Render swagger view
return $this->renderer->render($response, '/swagger/index.phtml', $arrray);
});
$app->group('/api', function () use ($app) {
require __DIR__ . '/src/Spearhead/Routes/routes_base.php';
})->add(new Authentication());
$app->group('/web', function () use ($app) {
$app->post('/login', function (Request $request, Response $response, array $args) {
return $response->withRedirect('/docs');
});
});
$app->run();
/src/Spearhead/settings.php
<?php
return [
'settings' => [
'displayErrorDetails' => true, // set to false in production
'addContentLengthHeader' => false, // Allow the web server to send the content-length header
"determineRouteBeforeAppMiddleware" => true,
// Renderer settings
'renderer' => [
'template_path' => __DIR__ . '/templates',
],
'mysqldb' => [
'driver' => 'mysql',
'host' => *****',
'database' => '*****',
'username' => '*****',
'password' => '*****@*****',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
],
'db' => [
'driver' => 'sqlsrv',
'host' => '*****',
'database' => '*****',
'username' => '*****',
'password' => '*****',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
],
'paystack_config' => [
'key' => '*****'
]
],
'pdb' => [
'user' => 'root',
'dbname' => 'fieldagents',
'pass' => '',
'host' => '127.0.0.1'
],
'mail_config' => [
'SMTPDebug' => 2,
'sendgridkey'=> ''
],
'upload_path' => [
'base' => __DIR__ . '/Upload',
'borrower' => '/Borrowers'
]
];
Thanks in advance