ijackua/yii2-gon 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ijackua/yii2-gon

最新稳定版本:1.0.0

Composer 安装命令:

composer require ijackua/yii2-gon

包简介

Push data from PHP controller to JS variable (inspired by https://github.com/gazay/gon)

README 文档

README

Latest Version on Packagist Software License Total Downloads

Push data from PHP controller to global JS variable (inspired by https://github.com/gazay/gon)

Install

Via Composer

$ composer require ijackua/yii2-gon

Configure

Add component to application config

'components' => array(
    'gon' => 'ijackua\gon\GonComponent'
),

And to app bootstrap section

$config = array(
    'bootstrap' => array('gon'),
    ...

Full component configuration example

'components' => array(
       'gon' => array(
            'class' => 'ijackua\gon\GonComponent',
            'jsVariableName' => 'gon',
            'globalData' => ['g1' => 1, 'g2' => '2'],
            'showEmptyVar' => true,
        )
),

Usage

Anywhere in your app push key -> value

\Yii::$app->gon->push('someObj', ['a'=>'b']);
\Yii::$app->gon->push('str', 'hello');

On JS side you will get

> window.gon
>> Object
      someObj: Object
         {
           a: "b"
         }
      str: "hello"

TODO

  • Make optional non-global usage. AMD, CommonJS modules.

Change log

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 6.18k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-14