# Error: I need help with MVC

**URL:** <https://discourse.slimframework.com/t/error-i-need-help-with-mvc/2727>\
**Category:** Questions\
**Created:** [October 12, 2018, 6:18pm UTC](https://discourse.slimframework.com/t/error-i-need-help-with-mvc/2727 "2018-10-12T18:18:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ana.baierle](https://avatars.discourse-cdn.com/v4/letter/a/9f8e36/32.png) [@ana.baierle](https://discourse.slimframework.com/u/ana.baierle)\
**Post date:** [October 12, 2018, 6:18pm UTC](https://discourse.slimframework.com/t/error-i-need-help-with-mvc/2727/1 "2018-10-12T18:18:57Z")

</div>

You are giving the following error:  
**Notice** : Undefined variable: app in **C:\xampp\htdocs\thesi\admin\services.php** on line **6**

**Fatal error** : Uncaught Error: Call to a member function get() on null in C:\xampp\htdocs\thesi\admin\services.php:6 Stack trace: #0 {main} thrown in **C:\xampp\htdocs\thesi\admin\services.php** on line **6**

I do not know how to solve, could someone help me?

Below is the admin folder with the

Bootstrap

```php
<?php
use Illuminate\Database\Capsule\Manager as Db;
include __DIR__. '/../vendor/autoload.php';

$db = new Db();

$db->addConnection([
    'driver' => 'pgsql',
    'host' => 'localhost',
    'database' => 'dbescola',
    'username' => 'postgres',
    'password' => 'ana1997',
    'charset' => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix' => ''
]);

$db->setAsGlobal();
$db->bootEloquent();

include __DIR__. '/app.php'; //nova linha

```

Services

```php
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
use Illuminate\Database\Capsule\Manager as Db;

$app->get('/aluno/', function () {
    $aluno = Db::table('aluno')->get();
    return json_encode($aluno);
});

```

app

```php
<?php
use Illuminate\Database\Capsule\Manager as Db;

$app = new Slim\App;

// autenticaÃ§Ã£o
$app->add(new Tuupola\Middleware\HttpBasicAuthentication([
    "users" => [
        "anam" => "anam",
        "anap" => "anap"
    ]
]));

include __DIR__. "/services.php";

$app->run();

```

---

<div class="post-metadata">

**Author:** ![Stjo](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/stjo/32/515_2.png) [@Stjo](https://discourse.slimframework.com/u/Stjo)\
**Post date:** [October 14, 2018, 8:34am UTC](https://discourse.slimframework.com/t/error-i-need-help-with-mvc/2727/2 "2018-10-14T08:34:21Z")

</div>

Im a little bit confused her?!.. Your Services.php looks like a route file? If thats the case, I would advice you to change your setup, so that your route calls a method in a controller instead of trying to query the database directly from your route…
