Q:

How to access to settings in routes in Slim PHP

I'm trying to access to settings in slim php 3.1
src/settings.php
<?php
return [
    'settings' => [
        'displayErrorDetails' => true, // set to false in production
        'addContentLengthHeader' => false, // Allow the web server to send the content-length header

        // Renderer settings
        'renderer' => [
            'template_path' => __DIR__ . '/../templates/',
        ],

        // Monolog settings
        'logger' => [
            'name' => 'slim-app',
            'path' => __DIR__ . '/../logs/app.log',
            'level' => \Monolog\Logger::DEBUG,
        ],
    ],
];

documentation says:

Retrieving Settings
As the settings are stored in the DI container so you can access them
  via the settings key in container factories. For example:
$settings = $container->get('settings')['logger'];
You can also access them in route callables via $this:
$app->get('/', function ($request, $response, $args) {
$loggerSettings = $this->get('settings')['logger'];
// ... 

});

public/index.php
require '../vendor/autoload.php';

$app = new \Slim\App;
$app->get('/profile/facebook/{id}', function (Request $request, Response $response)  use ($app){
    var_dump($this->get('settings')['logger']);
});

$app->run();

I get NULL .
What am I doing wrong?

A:

You need to pass the settings into the App:
require '../vendor/autoload.php';

use Slim\Http\Request;
use Slim\Http\Response;

$settings = include __DIR_ . '/../src/settings.php';
$app = new \Slim\App($settings);

$app->get('/profile/facebook/{id}', function (Request $request, Response $response) {
    var_dump($this->get('settings')['logger']);
});

$app->run();

