# Request is always null

**URL:** <https://discourse.slimframework.com/t/request-is-always-null/2125>\
**Category:** Questions\
**Created:** [January 1, 2018, 3:53pm UTC](https://discourse.slimframework.com/t/request-is-always-null/2125 "2018-01-01T15:53:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahesh](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@mahesh](https://discourse.slimframework.com/u/mahesh)\
**Post date:** [January 1, 2018, 3:53pm UTC](https://discourse.slimframework.com/t/request-is-always-null/2125/1 "2018-01-01T15:53:26Z")

</div>

I am using postman to send request to my localhost.

[http://localhost/slim/users?name=Mahesh](http://localhost/slim/users?name=Mahesh)  
NULL --\> Why is it null?

Routes.php  
\<?php

```
use App\Controllers\HomeController;
use App\Controllers\UserController;

$app->get('/', HomeController::class.':index');
$app->post('/users', UserController::class.':addUsers');

```

index.php

```
require "vendor/autoload.php";

$app = new Slim\App([

    'settings' => [
        'displayErrorDetails' => true,
        'db' => [
            'driver' => 'mysql',
            'host' => 'localhost',
            'database' => 'db',
            'username' => 'root',
            'password' => '',
            'charset' => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix' => '',
        ]
    ]
]);

$container = $app->getContainer();

use Illuminate\Database\Capsule\Manager as Capsule;
$capsule = new Capsule;

$capsule->addConnection($container['settings']['db']);
$capsule->setAsGlobal();
$capsule->bootEloquent();

$container['db'] = function($container) use ($capsule) {
    return $capsule;
};

require __DIR__. "/app/routes.php";

$app->run();

```

usercontroller

```
<?php

namespace App\Controllers;
use App\Models\User;

class UserController extends Controller {

    public function index( $response, $request ) {

        
    }

    public function addUsers( $request, $response) {
        
        var_dump($request->getBody());
        var_dump($request->getParsedBody());
    }
}

```

controller

```
<?php

namespace App\Controllers;

use Interop\Container\ContainerInterface;

class Controller {

    protected $container;
    public function __construct(ContainerInterface $c) {

        $this->container = $c;
    }
}

```

What is wrong in the coding?  
Does it follow good practices?

Please tell me. I am learning slim.

---

<div class="post-metadata">

**Author:** ![tstadler](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@tstadler](https://discourse.slimframework.com/u/tstadler)\
**Post date:** [January 1, 2018, 7:59pm UTC](https://discourse.slimframework.com/t/request-is-always-null/2125/2 "2018-01-01T19:59:07Z")

</div>

The request body is NULL, because the GET request you issued (via a browser ?) does not contain any body.

If you want to access the “name” query parameter of the URI, then you need to call

> $request-\>getUri()-\>getQuery()

or

> $request-\>getQueryParam(‘name’)
