Get language information of a user in Symfony

Code
<?php

use Symfony\Component\HttpFoundation\Request;

$request Request::createFromGlobals();

// Returns the preferred language
$preferredLang $request->getPreferredLanguage();

// Languages acceptable by the client browser
$languages $request->getLanguages();

var_dump($preferredLang$languages);
Result
NULL
array(0) {
}