PHPackages                             setono/consent-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. setono/consent-bundle

ActiveSymfony-bundle[Authentication &amp; Authorization](/categories/authentication)

setono/consent-bundle
=====================

A Symfony bundle that integrates the consent contracts

v1.2.0(1y ago)361.5k↓45%5MITPHPPHP &gt;=8.1

Since Aug 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Setono/ConsentBundle)[ Packagist](https://packagist.org/packages/setono/consent-bundle)[ RSS](/packages/setono-consent-bundle/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (9)Dependencies (13)Versions (11)Used By (5)

Symfony Consent Bundle
======================

[](#symfony-consent-bundle)

[![Latest Version](https://camo.githubusercontent.com/c0873c313fa77a21717a270ded6e2c1bc1f817438268bf85c307713c12ad109f/68747470733a2f2f706f7365722e707567782e6f72672f7365746f6e6f2f636f6e73656e742d62756e646c652f762f737461626c65)](https://packagist.org/packages/setono/consent-bundle)[![Software License](https://camo.githubusercontent.com/608c2bfd833c96dbf7536e0684c72e51c5dc9c66562ad43f9fff60e0c7f49dea/68747470733a2f2f706f7365722e707567782e6f72672f7365746f6e6f2f636f6e73656e742d62756e646c652f6c6963656e7365)](LICENSE)[![Build Status](https://github.com/Setono/ConsentBundle/workflows/build/badge.svg)](https://github.com/Setono/ConsentBundle/actions)[![Code Coverage](https://camo.githubusercontent.com/c48441df840934d855b4d5c77c9505c3fe31bad5cdf99c988ba8299309af2882/68747470733a2f2f636f6465636f762e696f2f67682f5365746f6e6f2f436f6e73656e7442756e646c652f6272616e63682f312e782f67726170682f62616467652e737667)](https://codecov.io/gh/Setono/ConsentBundle)[![Mutation testing](https://camo.githubusercontent.com/02bdf95b6af027db1f34fbb35235b3e517ed0b46901823c6bacacfe467af7c0e/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d2532465365746f6e6f253246436f6e73656e7442756e646c65253246312e78)](https://dashboard.stryker-mutator.io/reports/github.com/Setono/ConsentBundle/1.x)

This bundle integrates the [consent contracts](https://github.com/Setono/consent-contracts) into Symfony.

Installation
------------

[](#installation)

```
composer require setono/consent-bundle
```

This installs and enables the plugin automatically if you're using Symfony Flex. If not, add the bundle manually to `bundles.php`.

Configuration
-------------

[](#configuration)

### Consents

[](#consents)

The default configuration has all (default) consents (marketing, preferences, and statistics) set to `false`. If you want to change these defaults, you can easily do so:

```
# config/packages/setono_consent.yaml

setono_consent:
    consents:
        marketing: true
        preferences: true
        statistics: true
        random_consent: true # you can easily add your own consents
```

The above configuration will effectively change the default consent to `true` for all permissions.

### Consent checker

[](#consent-checker)

If you want to use a different consent checker, you can easily do so by implementing the `ConsentCheckerInterface` and setting your own service id as the consent checker:

```
# config/packages/setono_consent.yaml
setono_consent:
    consent_checker:
```

Usage
-----

[](#usage)

The bundle provides a `StaticConsentChecker` that uses the above `consents` array as an input. You can then autowire the `ConsentCheckerInterface` and check for a granted consent:

```
