Yii 2.0: yii2-js-urlmanager

That extension provide a way to create urls from your frontend part.
2 followers

Latest Stable Version License

Yii2 js UrlManager

Github repo

dmirogin/yii2-js-urlmanager

That extension provide a way to create urls from your frontend part.

Instalation

composer require dmirogin/yii2-js-urlmanager

How to use

  1. Add component to your application configuration
'jsUrlManager' => [
        'class' => \dmirogin\js\urlmanager\JsUrlManager::class,
    ],
  1. Add component to bootstrap
'bootstrap' => ['jsUrlManager'],
  1. Now you can use window.UrlManager or just UrlManager in your frontend part
       UrlManager.createUrl('foo/bar', {id: 10})

if you want to change assets position, use this

'assetManager' => [
    'bundles' => [
        \dmirogin\js\urlmanager\JsUrlManagerAsset::class => [
            'jsOptions' => [
                'position' => \yii\web\View::POS_END,
            ],
        ],
    ],
],

PHP options

configurationStringPosition - integer

Default value - \yii\web\View::POS_HEAD

The location to register configuration Frontend UrlManager string

'jsUrlManager' => [
    'class' => \dmirogin\js\urlmanager\JsUrlManager::class,
    'configurationStringPosition' => \yii\web\View::POS_END,
],

configureThroughVariable - boolean

Default value - false

Setting configuration through document variable urlManagerConfiguration

'jsUrlManager' => [
    'class' => \dmirogin\js\urlmanager\JsUrlManager::class,
    'configureThroughVariable' => true,
],

Contributing

  1. Clone project
  2. Write code
  3. Test
  4. Build js
    npm run test
    ./vendor/bin/phpunit
    npm run build

Be the first person to leave a comment

Please to leave your comment.

Create extension
Downloads
No downloadable files yet
  • Yii Version: 2.0
  • License: MIT License
  • Developed by: Dmitry Dorogin
  • Category: Others
  • Votes: +2
  • Downloaded: 0 times
  • Created on: Jul 8, 2017
  • Last updated: Jul 8, 2017