How do you setup Global Variables in Slim?

$app = new Slim\App();
$twig = $app->view-> getEnvironment();
$twig->addGlobal('foo', 'bar');

or

$app = new Slim\App();
$app->view['foo'] = 'bar';