PHP code example of quebecstudio-mods / consent-kit-core

1. Go to this page and download the library: Download quebecstudio-mods/consent-kit-core library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

quebecstudio-mods / consent-kit-core example snippets


use QuebecStudioMods\ConsentKit\Core\Bootstrap;
use QuebecStudioMods\ConsentKit\Core\Languages;
use QuebecStudioMods\ConsentKit\Core\Paths;
use QuebecStudioMods\ConsentKit\Core\Resolver;
use QuebecStudioMods\ConsentKit\Core\SiteContext;
use QuebecStudioMods\ConsentKit\Core\Templates;

$resolver = new Resolver(
    $settings,                                  // settings as a plain array
    new SiteContext($id, $handle, $locale),     // the site being served
    fn(string $value) => resolveEnv($value),    // `$ENV_VAR` references
    new Languages([$projectWordingFolder]),     // the project's wording files
);

$head = Bootstrap::script($resolver->bootstrapConfig());
$config = $resolver->bannerConfig($policyUrl);

$html = render(Paths::views('blade') . '/banner.blade.php', Templates::banner([
    'config' => $config,
    'texts' => $config['texts'],
    'categories' => $config['categories'],
]));