{"id":14109427,"url":"https://github.com/spatie/laravel-referer","last_synced_at":"2026-01-29T00:14:14.245Z","repository":{"id":43642973,"uuid":"80646641","full_name":"spatie/laravel-referer","owner":"spatie","description":"Remember a visitor's original referer","archived":false,"fork":false,"pushed_at":"2025-02-20T13:41:50.000Z","size":114,"stargazers_count":522,"open_issues_count":0,"forks_count":37,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-05-21T08:06:38.019Z","etag":null,"topics":["http","laravel","referer","seo"],"latest_commit_sha":null,"homepage":"https://freek.dev/686-a-package-to-remember-a-visitors-original-referer","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/spatie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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,"publiccode":null,"codemeta":null},"funding":{"github":"spatie","custom":"https://spatie.be/open-source/support-us"}},"created_at":"2017-02-01T17:48:12.000Z","updated_at":"2025-04-04T04:40:59.000Z","dependencies_parsed_at":"2024-04-08T08:44:30.448Z","dependency_job_id":"fad52377-006e-43c6-8c6e-5e366688cbd2","html_url":"https://github.com/spatie/laravel-referer","commit_stats":{"total_commits":99,"total_committers":23,"mean_commits":4.304347826086956,"dds":0.7272727272727273,"last_synced_commit":"9bd12d282ef6041a48cf5b1b2410e140d92d7131"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/spatie/laravel-referer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-referer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-referer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-referer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-referer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spatie","download_url":"https://codeload.github.com/spatie/laravel-referer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-referer/sbom","scorecard":{"id":840615,"data":{"date":"2025-08-11","repo":{"name":"github.com/spatie/laravel-referer","commit":"9424ec842822cd4bc2c408b813b385ca14eb007d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.6,"checks":[{"name":"Code-Review","score":2,"reason":"Found 5/19 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/php-cs-fixer.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/spatie/laravel-referer/php-cs-fixer.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/php-cs-fixer.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/spatie/laravel-referer/php-cs-fixer.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/php-cs-fixer.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/spatie/laravel-referer/php-cs-fixer.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/run-tests.yml:53: update your workflow using https://app.stepsecurity.io/secureworkflow/spatie/laravel-referer/run-tests.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/run-tests.yml:56: update your workflow using https://app.stepsecurity.io/secureworkflow/spatie/laravel-referer/run-tests.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/run-tests.yml:62: update your workflow using https://app.stepsecurity.io/secureworkflow/spatie/laravel-referer/run-tests.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/update-changelog.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/spatie/laravel-referer/update-changelog.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/update-changelog.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/spatie/laravel-referer/update-changelog.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/update-changelog.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/spatie/laravel-referer/update-changelog.yml/main?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   5 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/php-cs-fixer.yml:1","Warn: no topLevel permission defined: .github/workflows/run-tests.yml:1","Warn: no topLevel permission defined: .github/workflows/update-changelog.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: MIT License: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 16 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T20:24:00.103Z","repository_id":43642973,"created_at":"2025-08-23T20:24:00.103Z","updated_at":"2025-08-23T20:24:00.103Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28857264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T22:56:21.783Z","status":"ssl_error","status_checked_at":"2026-01-28T22:56:00.861Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["http","laravel","referer","seo"],"created_at":"2024-08-14T10:02:18.133Z","updated_at":"2026-01-29T00:14:14.232Z","avatar_url":"https://github.com/spatie.png","language":"PHP","funding_links":["https://github.com/sponsors/spatie","https://spatie.be/open-source/support-us"],"categories":["PHP"],"sub_categories":[],"readme":"# Remember a visitor's original referer\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/laravel-referer.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-referer)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![run-tests](https://github.com/spatie/laravel-referer/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/laravel-referer/actions/workflows/run-tests.yml)\n[![Total Downloads](https://img.shields.io/packagist/dt/spatie/laravel-referer.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-referer)\n\nRemember a visitor's original referer in session. The referer is (highest priority first):\n\n- The `utm_source` query parameter\n- The domain from the request's `Referer` header if there's an external host in the URL\n- Empty\n\n## Support us\n\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/laravel-referer.jpg?t=1\" width=\"419px\" /\u003e](https://spatie.be/github-ad-click/laravel-referer)\n\nWe invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).\n\nWe highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).\n\n## Installation\n\nYou can install the package via composer:\n\n``` bash\ncomposer require spatie/laravel-referer\n```\n\nThe package will automatically register itself in Laravel 5.5. In Laravel 5.4. you'll manually need to register the `Spatie\\Referer\\RefererServiceProvider` service provider in `config/app.php`.\n\nYou can publish the config file with:\n\n```\nphp artisan vendor:publish --provider=\"Spatie\\Referer\\RefererServiceProvider\"\n```\n\nPublishing the config file is necessary if you want to change the key in which the referer is stored in the session or\nif you want to disable a referer source.\n\n```php\nreturn [\n\n    /*\n     * The key that will be used to remember the referer in the session.\n     */\n    'session_key' =\u003e 'referer',\n\n    /*\n     * The sources used to determine the referer.\n     */\n    'sources' =\u003e [\n        Spatie\\Referer\\Sources\\UtmSource::class,\n        Spatie\\Referer\\Sources\\RequestHeader::class,\n    ],\n];\n```\n\n## Usage\n\nTo capture the referer, all you need to do is add the `Spatie\\Referer\\CaptureReferer` middleware to your middleware stack. In most configuration's, you'll only want to capture the referer in \"web\" requests, so it makes sense to register it in the `web` stack. Make sure it comes **after** Laravel's `StartSession` middleware!\n\n```php\n// app/Http/Kernel.php\n\nprotected $middlewareGroups = [\n    'web' =\u003e [\n        // ...\n        \\Illuminate\\Session\\Middleware\\StartSession::class,\n        // ...\n        \\Spatie\\Referer\\CaptureReferer::class,\n        // ...\n    ],\n    // ...\n];\n```\n\nThe easiest way to retrieve the referer is by just resolving it out of the container:\n\n```php\nuse Spatie\\Referer\\Referer;\n\n$referer = app(Referer::class)-\u003eget(); // 'google.com'\n```\n\nOr you could opt to use Laravel's automatic facades:\n\n```php\nuse Facades\\Spatie\\Referer\\Referer;\n\n$referer = Referer::get(); // 'google.com'\n```\n\nThe captured referer is (from high to low priority):\n\n- The `utm_source` query parameter, or:\n- The domain from the request's `Referer` header if there's an external host in the URL, or:\n- Empty\n\nAn empty referer will never overwrite an exisiting referer. So if a visitor comes from google.com and visits a few pages on your site, those pages won't affect the referer since local hosts are ignored.\n\n### Forgetting or manually setting the referer\n\nThe `Referer` class provides dedicated methods to forget, or manually set the referer.\n\n```php\nuse Facades\\Spatie\\Referer\\Referer;\n\nReferer::put('google.com');\nReferer::get(); // 'google.com'\nReferer::forget();\nReferer::get(); // ''\n```\n\n### Changing the way the referer is determined\n\nThe referer is determined by doing checks on various sources, which are defined in the configuration.\n\n```php\nreturn [\n    // ...\n    'sources' =\u003e [\n        Spatie\\Referer\\Sources\\UtmSource::class,\n        Spatie\\Referer\\Sources\\RequestHeader::class,\n    ],\n];\n```\n\nA source implements the `Source` interface, and requires one method, `getReferer`. If a source is able to determine a referer, other sources will be ignored. In other words, the `sources` array is ordered by priority.\n\nIn the next example, we'll add a source that can use a `?ref` query parameter to determine the referer. Additionally, we'll ignore `?utm_source` parameters.\n\nFirst, create the source implementations:\n\n```php\nnamespace App\\Referer;\n\nuse Illuminate\\Http\\Request;\nuse Spatie\\Referer\\Source;\n\nclass RefParameter implements Source\n{\n    public function getReferer(Request $request): string\n    {\n        return $request-\u003eget('ref', ''); \n    }\n}\n```\n\nThen register your source in the `sources` array. We'll also disable the `utm_source` while we're at it.\n\n```php\nreturn [\n    // ...\n    'sources' =\u003e [\n        App\\Referer\\RefParameter::class,\n        Spatie\\Referer\\Sources\\RequestHeader::class,\n    ],\n];\n```\n\nThat's it! Source implementations can be this simple, or more advanced if necessary.\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Testing\n\n``` bash\ncomposer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.\n\n## Security\n\nIf you've found a bug regarding security please mail [security@spatie.be](mailto:security@spatie.be) instead of using the issue tracker.\n\n## Credits\n\n- [Sebastian De Deyne](https://github.com/sebastiandedeyne)\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%2Fspatie%2Flaravel-referer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspatie%2Flaravel-referer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Flaravel-referer/lists"}