{"id":28676474,"url":"https://github.com/code16/cookie-consent","last_synced_at":"2025-06-13T23:04:48.095Z","repository":{"id":47823978,"uuid":"241321592","full_name":"code16/cookie-consent","owner":"code16","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-15T14:07:57.000Z","size":1035,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-06T03:05:42.481Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/code16.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-02-18T09:30:18.000Z","updated_at":"2021-11-04T18:42:35.000Z","dependencies_parsed_at":"2024-04-15T15:46:50.404Z","dependency_job_id":"85a13fb9-cc22-4ef4-88ed-37efe45bd09d","html_url":"https://github.com/code16/cookie-consent","commit_stats":{"total_commits":33,"total_committers":5,"mean_commits":6.6,"dds":0.303030303030303,"last_synced_commit":"8e0c6d8307780688a7a146a15c4240f2c8c4b595"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/code16/cookie-consent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code16%2Fcookie-consent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code16%2Fcookie-consent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code16%2Fcookie-consent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code16%2Fcookie-consent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/code16","download_url":"https://codeload.github.com/code16/cookie-consent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code16%2Fcookie-consent/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259732773,"owners_count":22903087,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-13T23:04:47.074Z","updated_at":"2025-06-13T23:04:48.082Z","avatar_url":"https://github.com/code16.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cookie consent\n\n## Setup\n```bash\ncomposer require code16/cookie-consent\n```\n\n**Required**: publish assets (add this in composer.json `post-autoload-dump` scripts)\n```php\nphp artisan vendor:publish --provider='Code16\\CookieConsent\\CookieConsentServiceProvider' --tag=assets --force\n```\n\nYou may publish the config file:\n\n```php\nphp artisan vendor:publish --provider=\"Code16\\CookieConsent\\CookieConsentServiceProvider\" --tag=config\n```\n\nAnd the lang file:\n\n```php\nphp artisan vendor:publish --provider=\"Code16\\CookieConsent\\CookieConsentServiceProvider\" --tag=lang\n```\n\n## Usage\n\n### Default\nIn your blade layout\n```blade\n\u003chead\u003e\n    {{-- ... --}}\n    @cookies\n        \u003cscript\u003e\n          {{-- some injected cookies --}}\n        \u003c/script\u003e\n    @endcookies\n\u003c/head\u003e\n\n\u003cbody\u003e\n    {{-- end of the body --}}\n    @include('cookieConsent::index')\n\u003c/body\u003e\n```\n\n### With category\nTo let the user manage multiple cookie categories (e.g. analytics, socials)\nAdd the category key to the `@cookies` directive\n```blade\n\u003chead\u003e\n    {{-- ... --}}\n\n    @cookies('analytics')\n        \u003cscript\u003e\n          {{-- some analytics script --}}\n        \u003c/script\u003e\n    @endcookies\n\u003c/head\u003e\n```\n\nAlso you must declare the cookie category in `config/cookie-consent.php` as follow\n```php\n[\n    'cookie_categories' =\u003e [\n        'system' =\u003e [\n            'required' =\u003e true,\n        ],\n        'analytics' =\u003e [],\n    ]\n];\n```\n\nCategories marked as `required` are cannot be opt-out by the user.\n\nTo provide explanation texts in the manage dialog, add content to the lang file:\n```php\n[\n    'manage' =\u003e [\n        'title' =\u003e 'Manage cookies',\n        'description' =\u003e 'About cookies...',\n        'categories' =\u003e [\n            'system' =\u003e [\n                'title' =\u003e 'System cookies',\n                'description' =\u003e \"Description text about system cookies\",\n            ],\n            'analytics' =\u003e [\n                'title' =\u003e 'Analytics cookies',\n                'description' =\u003e \"Description text about analytics cookies\",\n            ],\n        ],\n    ]\n];\n```\n\n### Show the manage modal from a link (e.g. cookies page)\nIn the page:\n```blade\n    @section('content')\n        \u003ca href=\"#manage-cookies\"\u003eOpen manage cookies modal\u003c/a\u003e\n    @endsection\n```\n\n### Intercept accept POST request\nIf you need to add some custom logic when cookies are accepted (meaning: either when the used clicked on OK in the Bar or after setting his choices on the Modal), you can define a Middleware in the cookie-consent-middleware config key, which will be executed on the POST request.\n\nExample:\n```php\n    // in config/cookie-consent.php\n    return [\n        // ...\n        'middleware' =\u003e 'cookie-consent.accepted'\n    ];\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode16%2Fcookie-consent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcode16%2Fcookie-consent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode16%2Fcookie-consent/lists"}