PHPackages                             linkuha/yii2-banner-resolver - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. linkuha/yii2-banner-resolver

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

linkuha/yii2-banner-resolver
============================

Banner Resolver based on region, probability and query parameters.

01PHP

Since Sep 16Pushed 7y ago1 watchersCompare

[ Source](https://github.com/linkuha/yii2-banner-resolver)[ Packagist](https://packagist.org/packages/linkuha/yii2-banner-resolver)[ RSS](/packages/linkuha-yii2-banner-resolver/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

### Banner Resolver component

[](#banner-resolver-component)

This is the Yii2 component for resolve what a banner is suitable for user with his query parameters, region (for example, by ip geolocation), and percent probabilities. You can to configure own rules for resolving a content.

As banner you can use any string, url, html code.

To install you need run comand (without `--no-dev` for testing capability support):

```
composer require linkuha/yii2-banner-resolver

```

**Tested on:**
PHP 7.2.0
Yii 2.0.14
Composer version 1.7.1
PHPUnit 7.3.5

**Rules types:**

- Region (country code with 2 symbols, you can get code from any IP Geo Location module, for example, if you have)

```
$RU = Yii::$app->geoip->lookupLocation('37.194.xxx.xxx')->countryCode;
```

- Percent (chance of choosing this rule with concrete probability. **NOT** can contain childrens due to his logic)
- Parameter (you can sent any array, e.g. request parameters array. resolver return a banner from rule matched to parameter)

Create in config directory file `banners.php`. And add configuration into your `'components' => [...]` section, for example:

```
$banners = require __DIR__ . '/banners.php';
...
'components' => [
    ...,
    'banners' => $banners,
]
```

Contains of config `banners.php` is may to be hierarchy with children key of associative array. Example:

```
