PHPackages                             vxm/yii2-js-params - 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. vxm/yii2-js-params

ActiveYii2-extension

vxm/yii2-js-params
==================

Support passed variables to javascript.

1.0.0(7y ago)675BSD-3-ClausePHPPHP ^7.1

Since Apr 21Pushed 7y ago2 watchersCompare

[ Source](https://github.com/vuongxuongminh/yii2-js-params)[ Packagist](https://packagist.org/packages/vxm/yii2-js-params)[ RSS](/packages/vxm-yii2-js-params/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Yii2 JS Params
==============

[](#yii2-js-params)

[![Latest Stable Version](https://camo.githubusercontent.com/5fa2659b8fe4fef3e7807f83c5c0c4372eacf28916b2f6c4a3a5d0f48d83142b/68747470733a2f2f706f7365722e707567782e6f72672f76786d2f796969322d6a732d706172616d732f762f737461626c65)](https://packagist.org/packages/vxm/yii2-js-params)[![Total Downloads](https://camo.githubusercontent.com/b21ccb724e74ab18b1e3fc32faed70aec8b616dfc6ed7cb00bdf9b29d6a21f60/68747470733a2f2f706f7365722e707567782e6f72672f76786d2f796969322d6a732d706172616d732f646f776e6c6f616473)](https://packagist.org/packages/vxm/yii2-js-params)[![Build Status](https://camo.githubusercontent.com/2d0c28e2851cd83cbc790be151e50b6cb1da69bcac8088fa1058589b546f730f/68747470733a2f2f7472617669732d63692e6f72672f76756f6e6778756f6e676d696e682f796969322d6a732d706172616d732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/vuongxuongminh/yii2-js-params)[![Code Coverage](https://camo.githubusercontent.com/7c00139789b57b49a8aa111a9f66edfd2b5af1470da3a2dc48d17e327fc6958b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f76756f6e6778756f6e676d696e682f796969322d6a732d706172616d732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/vuongxuongminh/yii2-js-params/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/cc3b4443ff8b1d5698788df02262b4f212afffc23e29c0db819fae2c6544e527/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f76756f6e6778756f6e676d696e682f796969322d6a732d706172616d732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/vuongxuongminh/yii2-js-params/?branch=master)[![Yii2](https://camo.githubusercontent.com/d6b0929173e28cc627430d2519ca1853466a70f37395877eaf4820cb3e1e1909/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506f77657265645f62792d5969695f4672616d65776f726b2d677265656e2e7376673f7374796c653d666c6174)](http://www.yiiframework.com/)

About it
--------

[](#about-it)

An extension provide an easy way to passed variables from your server to the JavaScript in rendering process of Yii2 view component.

Requirements
------------

[](#requirements)

- [PHP &gt;= 7.1](http://php.net)
- [yiisoft/yii2 &gt;= 2.0.13](https://github.com/yiisoft/yii2)

Installation
------------

[](#installation)

Require Yii2 JS Prams using [Composer](https://getcomposer.org):

```
composer require vxm/yii2-js-params
```

Usage
-----

[](#usage)

You can passed any variables you want when render view with addition `jsParams` element in view params:

```
use yii\web\Controller;

class TestController extends Controller
{

    public function actionTest()
    {
        return $this->render('test', [
            'jsParams' => [
                'test' => 'vxm'
            ]
        ]);
    }
}
```

And get this data on the frontend side from `window.serverParams`:

 [![](resource/demo.png)](resource/demo.png)

> Note: all variables will passed at View::POS\_HEAD please make sure a definition (`$this->head()`) on your layout file.

### Global params

[](#global-params)

Sometime you need to passed some params to all of view file, you can config it in your app config file:

```
'components' => [
    'view' => [
        'params' => [
            'jsParams' => ['test' => 'vxm']
        ]
    ]
]
```

Or config an anonymous function:

```
'components' => [
    'view' => [
        'params' => [
            'jsParams' => function() {

                return ['identity' => Yii::$app->user->identity->toArray()]
            }
        ]
    ]
]
```

Now use it on client side:

```

    console.log(window.serverParams.identity);

```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2576d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8901d64a1059726b851dbdd91463ad1d3169f9dba6a2dcff11d05f97d9bccaea?d=identicon)[vuongxuongminh](/maintainers/vuongxuongminh)

---

Top Contributors

[![vuongxuongminh](https://avatars.githubusercontent.com/u/38932626?v=4)](https://github.com/vuongxuongminh "vuongxuongminh (9 commits)")

---

Tags

js-paramsrendereryii2yii2-extensionyii2extensionpassed-variables

### Embed Badge

![Health badge](/badges/vxm-yii2-js-params/health.svg)

```
[![Health](https://phpackages.com/badges/vxm-yii2-js-params/health.svg)](https://phpackages.com/packages/vxm-yii2-js-params)
```

###  Alternatives

[skeeks/cms

SkeekS CMS — control panel and tools based on php framework Yii2

13825.6k46](/packages/skeeks-cms)[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)[richardfan1126/yii2-js-register

Yii2 widget to register JS into view

1357.2k7](/packages/richardfan1126-yii2-js-register)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
