Download the PHP package lemric/cookie-consent-bundle without Composer

On this page you can find all versions of the php package lemric/cookie-consent-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cookie-consent-bundle

Cookie Consent bundle for Symfony

As soon as you are collecting or processing personally identifiable information (short PII) you are obliged to allow your visitors to decide what information are collected. This cookie consent banner bundle helps you to help your users.

Symfony bundle to integrate a cookie consent dialog to your website and to handle cookies according to AVG/GDPR.

Installation

Step 1: Download using composer

In a Symfony application run this command to install and integrate Cookie Consent bundle in your application:

Step 2: Enable the bundle

When not using Symfony Flex, enable the bundle manually:

In AppKernel.php add the following line to the registerBundles() method:

or in config/bundles.php add the following line to the array:

Step 3: Enable the routing

When not using Symfony Flex, enable the bundles routing manually by adding the following lines to your config/routing.yml:

Step 4: Configure to your needs

By default, the most secure options are enabled. You can change the config in config/packages/cookie_consent.yaml:

Usage

Twig implementation

Load the cookie consent in Twig via render_esi ( to prevent caching ) at any place you like:

If you want to load the cookie consent with a specific locale you can pass the locale as a parameter:

You have to install assets like javascript for asynchronous form submission and default styles. To install these assets run:

Cookies

When a user submits the form the preferences are saved as cookies. The cookies have a lifetime of 180 days. The following cookies are saved:

In case the user rejects to usage of cookies, only the cookie named consent is saved with the current date as value.

Logging

AVG/GDPR requires all given cookie preferences of users to be explainable by the webmasters. For this we log all cookie preferences to the database. IP addresses are anonymized. You can disable logging the given consent by setting persist_consent to false.

Database logging

TwigExtension

The following TwigExtension functions are available:

cookieconsent_isCategoryAllowedByUser Check if user has given its permission for certain cookie categories.

cookieconsent_isCookieConsentOptionSetByUser Check if user has saved any cookie preferences. This will default to true even when the user chose to reject all cookies.

Customization

Categories

You can add or remove any category by changing the configuration option consent_categories and making sure there are translations available for these categories.

Translations

All texts can be altered via Symfony translations by overwriting the CookieConsentBundle translation files. Take a look at translations into any of the yaml files to get an idea of the structure.

Customization: Contents

Most of the blocks in this consent layer a customizable. The blocks are:

Create a file : templates/bundles/CookieConsentBundle/cookie_consent.html.twig and insert the following code:

Customization: Theming

A cookie consent form should be themeable and so is this.

Use symfony/form bundle

To use a different form theme from symfony/form bundle, stick to the Symfony documentation about rendering forms. Remember to load the scripts and styles that belong to the theme.

Define your own form theme

This bundle comes with a default theme. To use this particular theme, please add the following line to your config/packages/twig.yaml:

To use your very own theme, create a twig file under your templates folder and reference this twig file within your config/packages/twig.yaml under twig->form_themes like this:

This should include overwrites for block like choice_row and submit_row:

As Twig allows the loading of multiple themes, ensure that yours is the last one to overwrite blocks with the same name.

Styling

CookieConsentBundle comes with a default styling. A sass file is available in assets/css/cookie_consent.scss and a build css file is available in public/css/cookie_consent.css. Colors can easily be adjusted by setting the variables available in the sass file.

To apply the default styling to your website, include the following line in your twig template:

JavaScript: Events

When a form button is clicked, the event of cookie-consent-form-submit-successful is dispatched. Use the following code to listen to the event.

Troubleshoting

Error 500 after submitting the form

If your backend returns a response with HTTP status code 500 after submitting the form, make sure you have the route available for the configuration option form_action.


All versions of cookie-consent-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
doctrine/annotations Version ^1.6|^2.0
doctrine/doctrine-bundle Version ^1.10 || ^2.11.1
doctrine/orm Version ^2.12.0|^3.2.1
symfony/asset Version ^v6.3.0 || ^7.0
symfony/config Version ^v6.3.0 || ^7.0
symfony/dependency-injection Version ^v6.3.0 || ^7.0
symfony/doctrine-bridge Version ^6.3.0 || ^7.0
symfony/expression-language Version ^6.3 || ^7.0
symfony/form Version ^6.3 || ^7.0
symfony/http-kernel Version ^6.3.0 || ^7.0
symfony/security-csrf Version ^6.3.0 || ^7.0
symfony/translation Version ^6.3.0 || ^7.0
symfony/twig-bridge Version ^6.3.0 || ^7.0
symfony/twig-bundle Version ^6.3.0 || ^7.0
twig/twig Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lemric/cookie-consent-bundle contains the following files

Loading the files please wait ....