承接 hospect/php-vars-to-js-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

hospect/php-vars-to-js-bundle

最新稳定版本:1.0.2

Composer 安装命令:

composer require hospect/php-vars-to-js-bundle

包简介

Transformation of PHP vars to JS for Symfony2 with Twig

README 文档

README

Build Status

Description

Bundle allows you to avoid horrible statements in Twig templates while setting JS variables from PHP ones, like:

var someJsVar = '{{ somePhpVar }}',
    anotherJsVar = '{{ anotherPhpVar }}';

Installation

Simply require it with composer:

composer require hospect/php-vars-to-js-bundle

And register in your AppKernel.php:

public function registerBundles()
{
    $bundles = array(
        // some other bundles...
        
        new \Hospect\PhpVarsToJsBundle\HospectPhpToJsBundle(),
    );
        
    return $bundles;
}

Usage

In your controller call:

$this->get('php_to_js')->put([
    'someJsVar' => $somePhpVar,
    // more vars here...
]);

Then in Twig template (probably that will be useful to move it to layout):

<script>
    {{ initPhpVars() }}
</script>

统计信息

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

GitHub 信息

  • Stars: 9
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-16