1. Go to this page and download the library: Download yidas/yii2-nav-locator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yidas / yii2-nav-locator example snippets
use yidas\NavLocator as Locator;
use yii\helpers\Url;
public static boolean is(string $route)
use yidas\NavLocator as Locator;
Locator::is('site'); // False (Route `site` could not refer to a actual action)
Locator::is('site/'); // False (There is no difference between using a slash or not)
Locator::is('site/index'); // True (Successfully match the same controller ID and same action ID)
Locator::is('site/index/'); // True
Locator::is('site/other'); // False (Failed to match the same controller ID but the different action ID)
Locator::is('site/other/'); // False
public static boolean in(string $route)
use yidas\NavLocator as Locator;
Locator::in('site'); // True (Current route `site/index` is indeed in `site` layer)
Locator::in('site/'); // True
Locator::in('site/index'); // True (Current route `site/index` is indeed the `site/index` layers)
Locator::in('site/index/'); // True
Locator::in('site/other'); // False (Current route `site/index` is not in `site/other` layers)
Locator::in('site/other/'); // False
Locator::in('si'); // False (Current route `site/index` is not in `si` layer, `site` != `si`)
Locator::in('si/'); // False
Locator::in('site/index/index');// False (This route means `site` module with `index` controller and `index` action)