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
string(5) "en_US"
array(2) {
[0]=>
string(5) "en_US"
[1]=>
string(2) "en"
}
Used Versions
PHP 7.2, Zend 3.0, Symfony 4.0, Laravel 5.6, PHPUnit 6.5, Doctrine 2.8