Skip to content

Instantly share code, notes, and snippets.

@bizley
Created April 30, 2021 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bizley/b5dfd172dc27b730943afed921ee7757 to your computer and use it in GitHub Desktop.
Save bizley/b5dfd172dc27b730943afed921ee7757 to your computer and use it in GitHub Desktop.
FLoC Permissions Policy Header for Yii 2
<?php
/**
* This adds Permissions-Policy header to all Yii 2 app responses blocking FLoC.
* What is Federated Learning of Cohorts (FLoC)? - read https://web.dev/floc/
* Google’s FLoC Is a Terrible Idea - read https://www.eff.org/pl/deeplinks/2021/03/googles-floc-terrible-idea
*/
$config = [
// ... other configuration
'components' => [
// ... other components configuration
'response' => [
'on beforeSend' => function () {
Yii::$app->response->headers->add('permissions-policy', 'interest-cohort=()');
}
],
],
];
return $config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment