# How to get settings from Controller

**URL:** <https://discourse.slimframework.com/t/how-to-get-settings-from-controller/159>\
**Category:** Questions\
**Created:** [April 21, 2016, 7:45am UTC](https://discourse.slimframework.com/t/how-to-get-settings-from-controller/159 "2016-04-21T07:45:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheLobos](https://avatars.discourse-cdn.com/v4/letter/t/e9bcb4/32.png) [@TheLobos](https://discourse.slimframework.com/u/TheLobos)\
**Post date:** [April 21, 2016, 7:45am UTC](https://discourse.slimframework.com/t/how-to-get-settings-from-controller/159/1 "2016-04-21T07:45:13Z")

</div>

Hi,

I’m getting up to speed with Slim and I’m really liking it o far, it’s a breath of fresh air, especially after the byzantine labyrinth some other systems have evolved into (names shall not be mentioned 🙂).

I’m facing what is probably an entirely basic issue, but I haven’t been able to figure it out. My controller code looks like this:

```
    final class HomeAction
    {
        private $view;
        private $logger;
        private $hash;
        private $auth;
        private $session;
        private $jsonRequest;

        public function __construct (JsonRequest $jsonRequest, Twig $view, LoggerInterface $logger, $hash, $auth)
        {
            $this->view = $view;
            $this->logger = $logger;
            $this->hash = $hash;
            $this->auth = $auth;
            $this->session = new \App\Helper\Session;
            $this->jsonRequest = new JsonRequest();
            $this->JsonRender = new JsonRenderer();
        }

        public function dispatch (Request $request, Response $response, $args)
        {
            $this->view->render ($response, 'home.twig', [
                'user' => User::all (),

            ]);

            return $response;
        }

```

My question is that I need to access my application settings but I have no idea how to get an app/container context from the class variable available to me under this scope.

Any hints are highly appreciated.

---

<div class="post-metadata">

**Author:** ![akrabat](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/akrabat/32/9_2.png) [@akrabat](https://discourse.slimframework.com/u/akrabat)\
**Post date:** [April 21, 2016, 9:30am UTC](https://discourse.slimframework.com/t/how-to-get-settings-from-controller/159/2 "2016-04-21T09:30:03Z")

</div>

Pass in the settings that you need into the constructor.

Within your factory, they are in `$c->get('settings');`

---

<div class="post-metadata">

**Author:** ![TheLobos](https://avatars.discourse-cdn.com/v4/letter/t/e9bcb4/32.png) [@TheLobos](https://discourse.slimframework.com/u/TheLobos)\
**Post date:** [April 22, 2016, 10:30am UTC](https://discourse.slimframework.com/t/how-to-get-settings-from-controller/159/3 "2016-04-22T10:30:33Z")

</div>

Thanks, that worked like a charm.
