# Creating a custom request class

**URL:** <https://discourse.slimframework.com/t/creating-a-custom-request-class/2068>\
**Category:** Questions\
**Created:** [December 3, 2017, 12:02pm UTC](https://discourse.slimframework.com/t/creating-a-custom-request-class/2068 "2017-12-03T12:02:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sodhiar](https://avatars.discourse-cdn.com/v4/letter/s/ec9cab/32.png) [@sodhiar](https://discourse.slimframework.com/u/sodhiar)\
**Post date:** [December 3, 2017, 12:02pm UTC](https://discourse.slimframework.com/t/creating-a-custom-request-class/2068/1 "2017-12-03T12:02:13Z")

</div>

I’m trying to figure out if I can create a custom `$request` object in Slim 3, with some of my own custom methods. I saw [https://github.com/slimphp/Slim/issues/1480](https://github.com/slimphp/Slim/issues/1480) through which I wrote:

```
'settings' => [
	'request' => function ($c) {
		return \App\Request::createFromEnvironment($c['environment']);
	},
]

$app = new \Slim\App($settings);

```

Then in my routes:

```
$app->get('/systems', '\App\Controllers\SystemsController:index');

```

But in my controller method, my `$request` object doesn’t have any of the methods in my extended function. Not sure what I’m misunderstanding.

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [December 3, 2017, 11:05pm UTC](https://discourse.slimframework.com/t/creating-a-custom-request-class/2068/2 "2017-12-03T23:05:04Z")

</div>

This should do the trick:

```
$container['request'] = function ($container) {
    // Replace this class with your extended implementation
    return Request::createFromEnvironment($container['environment']);
};

```

PS: Maybe it would be better to implement a middlware for your purposes.
