{"id":27437428,"url":"https://github.com/keepsuit/laravel-cookie-solution","last_synced_at":"2025-10-03T18:49:17.142Z","repository":{"id":65509090,"uuid":"589540660","full_name":"keepsuit/laravel-cookie-solution","owner":"keepsuit","description":"Make your site comply with EU cookie law","archived":false,"fork":false,"pushed_at":"2025-04-14T09:18:15.000Z","size":522,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T10:28:11.524Z","etag":null,"topics":["consent","cookie","gdpr","laravel"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/keepsuit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2023-01-16T11:10:54.000Z","updated_at":"2025-04-14T09:18:19.000Z","dependencies_parsed_at":"2024-02-06T15:15:36.108Z","dependency_job_id":"ea128cf9-cf42-42db-be37-9d3e359e58bd","html_url":"https://github.com/keepsuit/laravel-cookie-solution","commit_stats":{"total_commits":74,"total_committers":3,"mean_commits":"24.666666666666668","dds":"0.17567567567567566","last_synced_commit":"453c4a2f4dbc3a00335d2b0a903f7614da79ee0c"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":"spatie/package-skeleton-laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keepsuit%2Flaravel-cookie-solution","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keepsuit%2Flaravel-cookie-solution/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keepsuit%2Flaravel-cookie-solution/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keepsuit%2Flaravel-cookie-solution/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keepsuit","download_url":"https://codeload.github.com/keepsuit/laravel-cookie-solution/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248863833,"owners_count":21174079,"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":["consent","cookie","gdpr","laravel"],"created_at":"2025-04-14T20:29:08.769Z","updated_at":"2025-10-03T18:49:17.134Z","avatar_url":"https://github.com/keepsuit.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Make your site comply with EU cookie law\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/keepsuit/laravel-cookie-solution.svg?style=flat-square)](https://packagist.org/packages/keepsuit/laravel-cookie-solution)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/keepsuit/laravel-cookie-solution/run-tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/keepsuit/laravel-cookie-solution/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/keepsuit/laravel-cookie-solution/fix-php-code-style-issues.yml?branch=main\u0026label=code%20style\u0026style=flat-square)](https://github.com/keepsuit/laravel-cookie-solution/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/keepsuit/laravel-cookie-solution.svg?style=flat-square)](https://packagist.org/packages/keepsuit/laravel-cookie-solution)\n\nThis package provides a configurable cookie banner for your Laravel application.\nIt also includes templates for cookie policy and privacy policy pages.\n\nNote that this package is not a legal advice.\nYou should always consult a lawyer and change texts and policies for your needs.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require keepsuit/laravel-cookie-solution\n```\n\nYou can publish the config file with:\n\n```bash\nphp artisan vendor:publish --tag=\"cookie-solution-config\"\n```\n\nThis is the contents of the published config file:\n\n```php\nreturn [\n    /**\n     * Enable or disable the cookie solution.\n     */\n    'enabled' =\u003e env('COOKIE_SOLUTION_ENABLED', true),\n\n    /**\n     * Name of the cookie where we store the user's consent.\n     */\n    'cookie_name' =\u003e 'laravel_cookie_solution',\n\n    /**\n     * The cookie's lifetime in days.\n     */\n    'cookie_lifetime' =\u003e 365,\n    \n    /**\n     * Banner highlight color (ex. #3522dd).\n     * If null, the default color will be used.\n     */\n    'highlight_color' =\u003e null,\n    \n    /**\n     * Floating banner toggle\n     * if false, the banner toggle will not be displayed.\n     * You need to add \"data-cookie-solution-toggle\" attribute to an element to open the banner.\n     */\n    'toggle_enabled' =\u003e true,\n    \n    /**\n     * Cookie toggle position (left or right).\n     */\n    'toggle_position' =\u003e 'right',\n    \n    /**\n     * The entity responsible for the processing of the data.\n     */\n    'data_owner' =\u003e [\n        /**\n         * Email address of the data owner.\n         */\n        'contact_email' =\u003e null,\n\n        /**\n         * Name/Company name and address of the data owner.\n         * This is parsed as Markdown (you can use __text__ for bold and _text_ for italic).\n         */\n        'name_and_address' =\u003e null,\n    ],\n];\n```\n\nOptionally, you can publish the assets, views and translations using.\n\n```bash\nphp artisan vendor:publish --tag=\"cookie-solution-assets\"\nphp artisan vendor:publish --tag=\"cookie-solution-views\"\nphp artisan vendor:publish --tag=\"cookie-solution-translations\"\n```\n\nIf you publish the assets, remember to publish new versions when you update the package.\nYou can automate this using composer `post-update-cmd` script:\n\n```json\n{\n    \"scripts\": {\n        \"post-update-cmd\": [\n            // ...\n            \"@php artisan vendor:publish --tag=cookie-solution-assets --force\"\n        ]\n    }\n}\n```\n\n## Usage\n\nInclude the cookie solution script in your layout (it's recommended to include it in the `\u003chead\u003e` tag):\n\n```blade\n@include('cookie-solution::script')\n```\n\nRegister used services in your 'AppServiceProvider' (You can register your own services with `Service` class):\n\n```php\n\u003c?php\n\nnamespace App\\Providers;\n\nuse Illuminate\\Support\\ServiceProvider;\nuse Keepsuit\\CookieSolution\\CookieSolution;\nuse Keepsuit\\CookieSolution\\ServiceFactories\\Google\\GoogleAnalytics4ServiceFactory;\nuse Keepsuit\\CookieSolution\\ServiceFactories\\Google\\GoogleDataProcessingLocation;\nuse Keepsuit\\CookieSolution\\ServiceFactories\\Google\\GoogleTagManagerServiceFactory;\nuse Keepsuit\\CookieSolution\\ServiceFactories\\Meta\\FacebookPixelServiceFactory;\nuse Keepsuit\\CookieSolution\\ServiceFactories\\Meta\\MetaDataProcessingLocation;\n\nclass AppServiceProvider extends ServiceProvider\n{\n    public function boot(): void\n    {\n        $this-\u003eapp-\u003eafterResolving(CookieSolution::class, function (CookieSolution $cookieSolution) {\n            $cookieSolution-\u003eregister(GoogleAnalytics4ServiceFactory::new()-\u003elocation(GoogleDataProcessingLocation::IRELAND)-\u003ebuild())\n                -\u003eregister(GoogleTagManagerServiceFactory::new()-\u003elocation(GoogleDataProcessingLocation::IRELAND)-\u003ebuild())\n                -\u003eregister(FacebookPixelServiceFactory::new()-\u003elocation(MetaDataProcessingLocation::IRELAND)-\u003ebuild());\n        });\n    }\n}\n```\n\nUpdate the config `config/cookie-consent.php` file with your data owner's contact email and name and address.\n\n```php\nreturn [\n    // ...\n    /**\n     * The entity responsible for the processing of the data.\n     */\n    'data_owner' =\u003e [\n        /**\n         * Email address of the data owner.\n         */\n        'contact_email' =\u003e 'your_email@example.com',\n\n        /**\n         * Name/Company name and address of the data owner.\n         * This is parsed as Markdown (you can use __text__ for bold and _text_ for italic).\n         */\n        'name_and_address' =\u003e \u003c\u003c\u003cMARKDOWN\n            __Your Company Name__\n            Your Street 1\n            City, Country\n            MARKDOWN,\n    ],\n];\n```\n\nCreate a route for the cookie policy page and include the cookie policy partial:\n\n```blade\n\u003cbody\u003e\n    @include('cookie-solution::cookie-policy')\n\u003c/body\u003e\n```\n\nCreate a route for the privacy policy page and include the privacy policy partial:\n\n```blade\n\u003cbody\u003e\n    @include('cookie-solution::privacy-policy')\n\u003c/body\u003e\n```\n\nSee [views customization](#views) section for more information about the partials and how to customize them.\n\n## Customization\n\n#### Highlight color\n\nYon can customize the highlight color of the banner and toggle changing the `highlight_color` config value.\n\n#### Toggle position\n\nYou can change the toggle position to `left` or `right` by changing the `toggle_position` config value (default to `right`).\nIf you need a more advanced customization, you can edit the toggle position with some CSS:\n\n```css\n:root {\n    --cs--toggle-position-bottom: 4rem; /* position from the bottom */\n    --cs--toggle-position-x: 2rem; /* position from the left or right (depending on `toggle_position` value) */\n}\n\n/* change the position for desktop */\n@media (min-width: 1024px) {\n    :root {\n        --cs--toggle-position-bottom: 2rem;\n        --cs--toggle-position-x: 1rem;\n    }\n}\n```\n\n#### Toggle z-index\n\nYou can change the toggle z-index by changing the `--cs--toggle-z-index` CSS variable. The default value is `9999`.\n\n#### Disabling toggle\n\nSometimes you may want to disable the default floating toggle and use your own toggle button.\nYou can do this by setting the `toggle_enabled` config value to `false`.\nThen you need to add the `data-cookie-solution-toggle` attribute to an element in your layout, like this:\n\n```html\n\u003cbutton data-cookie-solution-toggle\u003e\n    Toggle Cookie Banner\n\u003c/button\u003e\n```\n\n#### Views\n\nIf you want to customize the views, you can publish them with `php artisan vendor:publish --tag=\"cookie-solution-views\"` and style them however you like.\nThe `\u003ccookie-solution-policy-formatter/\u003e` custom component is used to apply the default styles, you can safely remove it to customize the views.\n\n## Checking status\n\nYou can check the user's consent status from laravel using the `CookieSolution::status()` method,\nwhich returns a `CookieSolutionStatus` object with helpers to check if a purpose has been accepted.\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Fabio Capucci](https://github.com/keepsuit)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeepsuit%2Flaravel-cookie-solution","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeepsuit%2Flaravel-cookie-solution","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeepsuit%2Flaravel-cookie-solution/lists"}