php - Declaring filter in application in Yii framework

one text

Solution:

You can attach behavior for application in its config. For example attaching ContentNegotiator in your frontend\config\main.php:

return [
    'as contentNegotiator' => [
        'class' => \yii\filters\ContentNegotiator::class,
        'formats' => [
            'application/json' => \yii\web\Response::FORMAT_JSON,
            'application/xml' => \yii\web\Response::FORMAT_XML,
        ],
        'languages' => [
            'en-US',
            'de',
        ],
    ],
    // ... other configuration ...
];

Source