2017 © Pedro Peláez
 

yii2-extension yii2-geofencing

Yii2 ActionFilter for allowing or denying access based on the visitors geo location

image

degordian/yii2-geofencing

Yii2 ActionFilter for allowing or denying access based on the visitors geo location

  • Saturday, February 17, 2018
  • by Degordian
  • Repository
  • 8 Watchers
  • 2 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 2 Versions
  • 56 % Grown

The README.md

Yii2 GeoFencing

An action filter that lets you allow or deny actions based on the visitors location., (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

composer require --prefer-dist degordian/yii2-geofencing "~1.0"

or add, (*4)

"degordian/yii2-geofencing": "~1.0"

to the require section of your composer.json file., (*5)

Usage

Once the extension is installed, add it to your controller, (*6)

  public function behaviors() {
    return [
      'class' => GeoIpAccessControl::class,
      'isoCodes' => ['HR', 'SI', 'RS'], //ISO 3166-1 alpha-2 two letter country code
      'filterMode' => GeoIpFilterMode::ALLOW, //allows only if you are listed in isoCodes,
      #'filterMode' => GeoIpFilterMode::DENY //allows only if you are not listed in isoCodes
      'getIp' => function() {
        //you can provide a custom function used to get the clients IP
        //defaults to Yii::$app->request->getUserIP()
      },
      'getIsoCode' => function($ip) {
        //you can provide a custom function used to get the iso code from the clients IP
        //by default uses lysenkobv/yii2-geoip
      },
      'message' => 'The message to display if the content is denied'
    ]
  }

Since this extends ActionFilter, you can use 'only' and 'except' to fine tune the geofencing criteria, (*7)

The Versions

17/02 2018

dev-master

9999999-dev

Yii2 ActionFilter for allowing or denying access based on the visitors geo location

  Sources   Download

MIT

The Requires

 

by Marko Kruljac

extension yii2 degordian geofencing

13/06 2017

v1.0.0

1.0.0.0

Yii2 ActionFilter for allowing or denying access based on the visitors geo location

  Sources   Download

Apache-2.0

The Requires

 

by Marko Kruljac

extension yii2 degordian geofencing