├── .php_cs.dist.php ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── composer.json └── src ├── DisableFloc.php └── DisableFlocServiceProvider.php /.php_cs.dist.php: -------------------------------------------------------------------------------- 1 | in([ 5 | __DIR__ . '/src', 6 | __DIR__ . '/tests', 7 | ]) 8 | ->name('*.php') 9 | ->notName('*.blade.php') 10 | ->ignoreDotFiles(true) 11 | ->ignoreVCS(true); 12 | 13 | return (new PhpCsFixer\Config()) 14 | ->setRules([ 15 | '@PSR2' => true, 16 | 'array_syntax' => ['syntax' => 'short'], 17 | 'ordered_imports' => ['sort_algorithm' => 'alpha'], 18 | 'no_unused_imports' => true, 19 | 'not_operator_with_successor_space' => true, 20 | 'trailing_comma_in_multiline' => true, 21 | 'phpdoc_scalar' => true, 22 | 'unary_operator_spaces' => true, 23 | 'binary_operator_spaces' => true, 24 | 'blank_line_before_statement' => [ 25 | 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], 26 | ], 27 | 'phpdoc_single_line_var_spacing' => true, 28 | 'phpdoc_var_without_name' => true, 29 | 'method_argument_space' => [ 30 | 'on_multiline' => 'ensure_fully_multiline', 31 | 'keep_multiple_spaces_after_comma' => true, 32 | ], 33 | 'single_trait_insert_per_statement' => true, 34 | ]) 35 | ->setFinder($finder); 36 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `laravel-disable-floc` will be documented in this file. 4 | 5 | ## 1.0.2 - 2022-02-01 6 | 7 | - Add support for PHP 8.1 8 | - Add support for Laravel 9 9 | 10 | ## 1.0.1 - 2021-05-06 11 | 12 | - remove unused dependencies (#3) 13 | 14 | ## 1.0.0 - 2021-05-05 15 | 16 | - initial release 17 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) spatie 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | [](https://supportukrainenow.org) 3 | 4 | # Automatically disable Google's FLoC in Laravel apps 5 | 6 | [![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/laravel-disable-floc.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-disable-floc) 7 | [![run-tests](https://github.com/spatie/laravel-disable-floc/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/laravel-disable-floc/actions/workflows/run-tests.yml) 8 | [![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/spatie/laravel-disable-floc/Check%20&%20fix%20styling?label=code%20style)](https://github.com/spatie/laravel-disable-floc/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amaster) 9 | [![Total Downloads](https://img.shields.io/packagist/dt/spatie/laravel-disable-floc.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-disable-floc) 10 | 11 | This package will automatically disable [Google's FLoC](https://plausible.io/blog/google-floc). 12 | 13 | ## Support us 14 | 15 | [](https://spatie.be/github-ad-click/laravel-disable-floc) 16 | 17 | We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us). 18 | 19 | We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards). 20 | 21 | ## Installation 22 | 23 | You can install the package via composer: 24 | 25 | ```bash 26 | composer require spatie/laravel-disable-floc 27 | ``` 28 | 29 | ## Usage 30 | 31 | After you've installed the package via composer, you're done. There's no step two. 32 | 33 | This package will automatically register the `DisableFloc` middleware in the web group. The middleware will add a header `Permissions-Policy` that will effectively disable FLoC. This header will be applied to all responses that have no `Permissions-Policy` header. 34 | 35 | ## Testing 36 | 37 | ```bash 38 | composer test 39 | ``` 40 | 41 | ## Changelog 42 | 43 | Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. 44 | 45 | ## Contributing 46 | 47 | Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details. 48 | 49 | ## Security vulnerabilities 50 | 51 | Please review [our security policy](../../security/policy) on how to report security vulnerabilities. 52 | 53 | ## Credits 54 | 55 | - [Freek Van der Herten](https://github.com/freekmurze) 56 | - [All Contributors](../../contributors) 57 | 58 | ## License 59 | 60 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 61 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "spatie/laravel-disable-floc", 3 | "description": "Automatically disable Google's floc in Laravel apps", 4 | "keywords": [ 5 | "spatie", 6 | "laravel", 7 | "laravel-disable-floc" 8 | ], 9 | "homepage": "https://github.com/spatie/laravel-disable-floc", 10 | "license": "MIT", 11 | "authors": [ 12 | { 13 | "name": "Freek Van der Herten", 14 | "email": "freek@spatie.be", 15 | "role": "Developer" 16 | } 17 | ], 18 | "require": { 19 | "php": "^7.3|^7.4|^8.0", 20 | "illuminate/contracts": "^7.30|^8.37|^9.0" 21 | }, 22 | "require-dev": { 23 | "orchestra/testbench": "^6.15|^7.0", 24 | "phpunit/phpunit": "^9.3" 25 | }, 26 | "autoload": { 27 | "psr-4": { 28 | "Spatie\\DisableFloc\\": "src" 29 | } 30 | }, 31 | "autoload-dev": { 32 | "psr-4": { 33 | "Spatie\\DisableFloc\\Tests\\": "tests" 34 | } 35 | }, 36 | "scripts": { 37 | "psalm": "vendor/bin/psalm", 38 | "test": "./vendor/bin/testbench package:test --parallel --no-coverage", 39 | "test-coverage": "vendor/bin/phpunit --coverage-html coverage" 40 | }, 41 | "config": { 42 | "sort-packages": true 43 | }, 44 | "extra": { 45 | "laravel": { 46 | "providers": [ 47 | "Spatie\\DisableFloc\\DisableFlocServiceProvider" 48 | ] 49 | } 50 | }, 51 | "minimum-stability": "dev", 52 | "prefer-stable": true 53 | } 54 | -------------------------------------------------------------------------------- /src/DisableFloc.php: -------------------------------------------------------------------------------- 1 | headers->has('Permissions-Policy')) { 16 | $response->header('Permissions-Policy', 'interest-cohort=()'); 17 | } 18 | } 19 | 20 | return $response; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/DisableFlocServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->make(Kernel::class)->prependMiddlewareToGroup('web', DisableFloc::class); 13 | } 14 | } 15 | --------------------------------------------------------------------------------