sumanion / laravel-cloudflare
Simple way to determine real client IP and country when using CloudFlare
Installs: 3 146
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 1
Forks: 5
Type:laravel-package
Requires
- php: >=7.0
- illuminate/container: ^5.3
- illuminate/http: ^5.3
- illuminate/support: ^5.3
- symfony/http-foundation: ^3.1
Requires (Dev)
- mockery/mockery: ^0.9.5
- phpunit/phpunit: ~5.0
This package is not auto-updated.
Last update: 2020-10-30 22:15:08 UTC
README
This Laravel package helps to determine the IP address and current country of the client when using CloudFlare.
Installation
From the command line, run:
composer require sumanion/laravel-cloudflare
Available Methods
-
SumanIon\CloudFlare::isTrustedRequest():bool
- Returnstrue
when current request is coming from CloudFlare, otherwise returnsfalse
. -
SumanIon\CloudFlare::onTrustedRequest(Closure):mixed
- Executes theCallback
and returns it's return value when current request is coming from CloudFlare, otherwise returnsnull
. -
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.