https://github.com/timoschwarzer/laravel-cloudflare
Simple way to determine IP address and current country of the client when using CloudFlare
https://github.com/timoschwarzer/laravel-cloudflare
Last synced: 3 months ago
JSON representation
Simple way to determine IP address and current country of the client when using CloudFlare
- Host: GitHub
- URL: https://github.com/timoschwarzer/laravel-cloudflare
- Owner: timoschwarzer
- License: mit
- Created: 2017-09-17T13:31:58.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-17T13:32:38.000Z (almost 8 years ago)
- Last Synced: 2025-03-22T21:05:24.751Z (3 months ago)
- Language: PHP
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# CloudFlare for Laravel
This [Laravel](https://laravel.com/) package helps to determine
the IP address and current country of the client
when using [CloudFlare](https://cloudflare.com).## Installation
From the command line, run:
```
composer require sumanion/laravel-cloudflare
```## Available Methods
- [`SumanIon\CloudFlare::isTrustedRequest():bool`]() -
Returns `true` when current request is coming from *CloudFlare*,
otherwise returns `false`.- [`SumanIon\CloudFlare::onTrustedRequest(Closure):mixed`]() -
Executes the `Callback` and returns it's return value
when current request is coming from *CloudFlare*, otherwise returns `null`.- [`SumanIon\CloudFlare::ip():string`]() -
Returns current IP address of the client.> **Note:** When a website is using *CloudFlare* nameservers
> the `$_SERVER['REMOTE_ADDR']` points to *CloudFlare*, and we have
> to do extra validation to get "the real" IP address of the client.- [`SumanIon\CloudFlare::country():string`]() -
Returns current country of the client.> **Note:** *CloudFlare* usually sends a `CF_IPCOUNTRY` HTTP header
> with current country of the client.