Download the PHP package lukeyouell/craft-geocookie without Composer

On this page you can find all versions of the php package lukeyouell/craft-geocookie. 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 craft-geocookie

Geo Cookie plugin for Craft CMS 3.x

Collect information about a visitor's location based on their IP address and store the information as a cookie.

Requirements

This plugin requires Craft CMS 3.0.0 or later.

Installation

To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:

    cd /path/to/project
  2. Then tell Composer to load the plugin:

    composer require lukeyouell/craft-geocookie
  3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Geo Cookie.

Configuring Geo Cookie

IP Anonymisation

Anonymisation is the process of turning data into a form which does not identify individuals and where identification is not likely to take place. This allows for a much wider use of the information.

You can toggle this on/off in the CP.

API Sources

There are currently 8 different API's to choose from:

API Key

You can supply an API key, should your chosen API source require one.

Request Timeout

You can specify the number of seconds to allow for the request to take place before timing out. The default value is 5 seconds.

Fallback IP Address

This will be used as the fallback ip address, should the plugin fail to source the user's ip address.

Default value is 8.8.8.8 (Google Inc.)

Cookie Name

The default value is geoCookie although you can change this to whatever you like.

To purge existing cookies simply change the name of the cookie.

Cookie Duration

The user's location is stored in a cookie, you can define the length of time this cookie should exist.

The current options are:

Using Geo Cookie

Setting the Variable

{% set location = geocookie() %}

The location variable gives you access to the geolocation data.

Example Usage

JSON Response (ipapi.co)
Usage
Key Usage Output
ip {{ location.ip }} 8.8.8.8
city {{ location.city }} Mountain View
region {{ location.region }} California
region_code {{ location.region_code }} CA
country {{ location.country }} US
country_name {{ location.country_name }} United States
postal {{ location.postal }} 94035
latitude {{ location.latitude }} 37.386
longitude {{ location.longitude }} -122.0838
timezone {{ location.timezone }} America/Los_Angeles
asn {{ location.asn }} AS15169
org {{ location.org }} Google Inc.
Caching

If an active cookie matching the cookie name in the settings exists, the plugin will use the location stored within the cookie instead of performing another API request.

To check if a cookie exists simply use location.cached which will return a boolean true/false response.

Example API Responses

db-ip.com

extreme-ip-lookup.com
freegeoip.net
ip-api.com
ipapi.co
ipfind.co
ipinfo.io
ipvigilante.com
keycdn.com

Overriding Plugin Settings

If you create a config file in your config folder called geo-cookie.php, you can override the plugin’s settings in the Control Panel. Since that config file is fully multi-environment aware, this is a handy way to have different settings across multiple environments.

Here’s what that config file might look like along with a list of all of the possible values you can override.

Parameter Expected Value
logging Boolean
anonymisation Boolean
apiSource extremeiplookup, freegeoip, ipapi, ipapi.com, ipfind, ipinfo, 'ipvigilante', keycdn or db-ip
apiKey API key for chosen source
requestTimeout Integer (seconds)
fallbackIp Valid IP address
cookieName Cookie name
cookieDuration Integer (hours)

Debugging

You can dump the API response:

Errors are now logged. Simply search your logs for geocookie.

Geo Cookie Roadmap

Some things to do, and ideas for potential features:

Brought to you by Luke Youell


All versions of craft-geocookie with dependencies

PHP Build Version
Package Version
Requires craftcms/cms Version ^3.0.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 lukeyouell/craft-geocookie contains the following files

Loading the files please wait ....