Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Hagreed Bundle Laravel Package

alteis/hagreed-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Install the Bundle
    composer require alteis/hagreed-bundle
    
  2. Configure .env Add your Hagreed token:
    HAGREED_TOKEN="your-token-from-hagreed.com"
    
  3. Register the Bundle Add to config/bundles.php:
    Alteis\HagreedBundle\AlteisHagreedBundle::class => ['all' => true],
    
  4. Add to Twig Include in your base template:
    <head>
        {{ header_hagreed() }}
    </head>
    <body>
        {{ body_end_hagreed() }}
    </body>
    

First Use Case: Basic Consent Banner

  • Trigger the banner via JavaScript:
    <a href="javascript:window.hagreedBundle.displayBanner()">Manage Cookies</a>
    
  • Verify functionality by testing cookie consent storage in browser dev tools.

Implementation Patterns

Core Workflow: Consent Management

  1. Initialization
    • Configure alteis_hagreed.yaml with:
      alteis_hagreed:
          token: '%env(HAGREED_TOKEN)%'
          timeout: 5000  # Auto-show delay (ms)
          turbo: true     # If using Hotwire Turbo
      
  2. Customize Consents Define cookie categories and purposes in YAML:
    cookies:
        - id: analytics
          name: "Analytics"
          category: STATISTICS
          link: "https://example.com/privacy"
    
  3. Form Integration Map forms to consent purposes:
    consents_form_list:
        - id: contact_form
          title: "Data Processing"
          purposes:
              - slug: "marketing"
                name: "Receive newsletters"
                mandatory: false
    
  4. Export Consents Fetch user consents via:
    $consents = $this->apiHagreed->exportConsents($userEmail);
    

Integration Tips

  • Turbo Compatibility: Set turbo: true to avoid banner reloading on SPA transitions.
  • Language Handling: Force language via force_lang: true or auto-detect with lang: fr|en.
  • Dynamic Templates: Override default templates by extending the bundle’s Twig paths.

Gotchas and Tips

Pitfalls

  1. Turbo Conflicts
    • Issue: Banner reappears on Turbo-driven navigation.
    • Fix: Set turbo: true in config and ensure importmap.php includes:
      '@tizy/hagreed/hagreed.js' => ['version' => '1.2.7'],
      
  2. Token Validation
    • Issue: Silent failures if HAGREED_TOKEN is invalid.
    • Debug: Check Symfony logs for API errors or use:
      php bin/console debug:config alteis_hagreed
      
  3. Cookie Storage
    • Issue: Consents not persisting across subdomains.
    • Fix: Configure SameSite and Domain attributes in Hagreed’s dashboard.

Debugging

  • API Calls: Use ApiHagreedInterface to test endpoints:
    $this->apiHagreed->exportConsents('test@example.com');
    
  • Twig Errors: Clear cache after template changes:
    php bin/console cache:clear
    

Extension Points

  1. Custom Templates Override templates/alteis_hagreed/ in your bundle to modify banner UI.
  2. Event Listeners Extend consent logic via Symfony events (e.g., hagreed.consent.saved).
  3. Advanced Config Use environment variables for dynamic settings:
    timeout: '%env(int:HAGREED_TIMEOUT)%'
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle