tempo/jsconfiguration-bundle

此包已被废弃,不再维护。未建议替代包。

一种非常不错地将配置暴露给JavaScript的方法。

安装: 207

依赖者: 0

建议者: 0

安全: 0

星标: 1

关注者: 4

分支: 0

类型:symfony-bundle

0.5 2016-06-02 20:23 UTC

This package is auto-updated.

Last update: 2023-12-04 14:34:49 UTC


README

此包允许您将配置暴露在JavaScript代码中。

安装

在您的composer.json文件中添加tempo/jsconfiguration-bundle

{
    "require": {
        "tempo-project/jsconfiguration-bundle": "dev-master"
    }
}

app/AppKernel.php中注册包

// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new Tempo\Bundle\JsConfigurationBundle\TempoJsConfigurationBundle(),
    );
}

发布资源

$ php app/console tempo:js-configuration:dump
$ php app/console assets:install --symlink web

用法

此外,您可以在app/config/config.yml中配置要暴露的配置列表

# app/config/config.yml

tempo_js_configuration:
  config_to_expose: [mopa_bootstrap.form.show_legend]

在您的布局中添加这两行

<script src="{{ asset('bundles/tempojsconfiguration/js/configuration.js') }}"></script>
<script src="{{ asset('js/tempo_configuration.js') }}"></script>

测试

使用Composer设置测试套件

$ composer install --dev

使用PHPUnit运行它

$ phpunit

资源