Download the PHP package cloudflare/cf-ip-rewrite without Composer

On this page you can find all versions of the php package cloudflare/cf-ip-rewrite. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cf-ip-rewrite

Cloudflare PHP IP Rewriting

This module makes it easy for developers to add rewrite Cloudflare IP Addresses for actual end-user IP Addresses at the application layer. It is recommended to either install mod_cloudflare for Apache or use nginx rewrite rules (https://support.cloudflare.com/hc/en-us/articles/200170706-Does-CloudFlare-have-an-IP-module-for-Nginx-) if possible.

For those cases, where the IP can not be guaranteed to be rewritten by one of these alternate means, this module can be used to rewrite the IP address.

How it works

The class exposes three methods for interaction and a constructor.

Initializing IpRewrite() object will try to rewrite the IP. If the IP is rewritten, $_SERVER["REMOTE_ADDR"] will be updated to reflect the end-user's IP address.

isCloudFlare(); returns true if the CF_CONNECTING_IP header is present in the request and the request originates from a Cloudflare IP.

getRewrittenIP() Returns the rewritten ip address if a rewrite occurs, otherwise it will return null.

getOriginalIP() returns the saved original ip address from $_SERVER["REMOTE_ADDR"].

Best Pratice

Caution

Rewrite action is triggered only once in constructor. If getRewrittenIP() or getOriginalIP() is called multiple times it'll return the first result regardless if a change happened after the first call. Since rewrite action was not triggered.

To get the newest changes a new IpRewrite object should be used.

Testing this module

This module comes with a set of tests that can be run using phpunit. To run the tests, run composer install on the package and then one of the following commands:

Basic Tests

composer test

With code coverage report in coverage folder

vendor/bin/phpunit -c phpunit.xml.dist --coverage-html coverage

All versions of cf-ip-rewrite with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package cloudflare/cf-ip-rewrite contains the following files

Loading the files please wait ....