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) {
}
Used Versions
PHP 7.2, Zend 3.0, Symfony 4.0, Laravel 5.6, PHPUnit 6.5, Doctrine 2.8