# Uncaught ArgumentCountError: Too few arguments to function Slim\\App::\_\_construct()

**URL:** <https://discourse.slimframework.com/t/uncaught-argumentcounterror-too-few-arguments-to-function-slim-app-construct/4511>\
**Category:** Questions\
**Created:** [November 17, 2020, 8:13am UTC](https://discourse.slimframework.com/t/uncaught-argumentcounterror-too-few-arguments-to-function-slim-app-construct/4511 "2020-11-17T08:13:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kolade](https://avatars.discourse-cdn.com/v4/letter/k/ecc23a/32.png) [@Kolade](https://discourse.slimframework.com/u/Kolade)\
**Post date:** [November 17, 2020, 8:13am UTC](https://discourse.slimframework.com/t/uncaught-argumentcounterror-too-few-arguments-to-function-slim-app-construct/4511/1 "2020-11-17T08:13:35Z")

</div>

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

```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
    <?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

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [November 17, 2020, 11:19am UTC](https://discourse.slimframework.com/t/uncaught-argumentcounterror-too-few-arguments-to-function-slim-app-construct/4511/2 "2020-11-17T11:19:04Z")

</div>

It looks like you have Slim version 4 installed, but your setup looks to be setup for Slim version 3. What does your `composer.json` file look like for `slim/slim` and how did you install Slim?
