Download the PHP package azine/geoblocking-bundle without Composer
On this page you can find all versions of the php package azine/geoblocking-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download azine/geoblocking-bundle
More information about azine/geoblocking-bundle
Files in azine/geoblocking-bundle
Package geoblocking-bundle
Short Description Bundle to filter/geoblock the access of visitors to your pages by location
License MIT
Homepage https://github.com/azine/geoblocking-bundle
Informations about the package geoblocking-bundle
Simple GeoBlocking-Bundle
Symfony2 Bundle that allows you to configure geoblocking access to certain pages of your application.
It adds an kernel event listener that listens for "kernel.request" events and uses the php geoip module to identify the country of origin of the current request and depending on the configuration displays an error-page.
Requirements
There are no explicit requirements. BUT the default setup makes two assumptions:
1. the php geoip-module is enabled on your server or you installed and configured the Maxmind/GeoIP Bundle
"DefaultLookupAdapter" uses the php function geoip_country_code_by_name($address) to find the country of the given address.
To use the default implementation, this function (provided by the php geoip module => http://www.php.net/manual/en/book.geoip.php) must be available.
Alternatively you can use the MaxmindLookupAdapter (from the Maxmind/GeoIP-Bundle => "maxmind/geoip": "dev-master"), which requires that the MaxmindGeoIPBundle is installed and configured.
Or you can implement and use your own GeoLookupAdapter that uses an other way to find the country for the given ip (see below).
2. you use fosuserbundle for authentication/usermanagment
Most often you would like that registered users can access your site from wherever they are. So there should be a option to login and for logged in users no pages should be blocked. As a lot of people (including me) use the fosuserbundle for user managment, the default configuration is set to work nicely with the default configuration of the fosuserbundle.
You can change this of course in the config.yml.
Installation
To install AzineGeoBlockingBundle with Composer just add the following to your composer.json file:
Then, you can install the new dependencies by running Composer’s update command from the directory where your composer.json file is located:
Now, Composer will automatically download all required files, and install them for you. All that is left to do is to update your AppKernel.php file, and register the new bundle:
Configuration options
For the bundle to work with the default-settings, no config-options are required. The default blocks all anonymouse users unless they are in the same private subnet (=> both server & client are inside the same home/company network) or on localhost (=> web-server and client are the same computer, e.g. when debugging locally).
This is the complete list of configuration options with their defaults.
Allow user by cookie
There are special cases where you want to allow visitors full access to your site even though they are not (yet) registered. For example allow an invited user to see all the pages, before signing up.
To allow this, you can set a coockie (named: geoblocking_allow_cookie, value true) that disables the geoblocking for a while.
To allow "invited" users to check out the site before registering, add this code to the action handling the first page view of an invited user to set the cookie:
Update your config.yml to enable the "allow_by_cookie"-feature and to allow the route that sets the cookie
Alternative GeoIpLookupAdapter
You can create your own implementation of Adapter\GeoIpLookupAdapterInterface.php, define it as service in your service.yml or service.xml and set the service-id as lookup_adapter in the config.yml: