appneta/traceview-twig 问题修复 & 功能扩展

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

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

appneta/traceview-twig

最新稳定版本:v0.1.0

Composer 安装命令:

composer require appneta/traceview-twig

包简介

Additional Twig integration for AppNeta TraceView.

README 文档

README

A Symfony request profiled in TraceView.

The AppNeta\TraceViewTwig package provides integration points between Twig and AppNeta TraceView. It currently supports:

  • Tracking Twig template rendering as profiles
  • Injecting real user monitoring JavaScript (via Twig extension)

Template Tracking

Twig template tracking is provided by replacing the Twig base template class with a TraceView-augmented one. The easiest way to load the relevant base template class is to add this package as a require in your composer.json:

    "require": {
        "php": ">=5.3.3",
        [...]
        "appneta/traceview-twig": "master@dev"
    },

If you're using Twig with Symfony2, you can add this line to the twig section of your config.yml:

twig:
    base_template_class: AppNeta\TraceViewTwig\Template\TraceViewTwigTemplate

If you're manually constructing a Twig environment, you should instead use the base_template_class option:

$options = array(
    'cache' => ...,
    'base_template_class' => AppNeta\TraceViewTwig\Template\TraceViewTwigTemplate
);
$twigEnv = new Twig_Environment($loader, $options);

Real User Monitoring

TraceView real user monitoring JavaScript is usually added by calling the oboe_get_rum_header and oboe_get_rum_footer functions. Because Twig templates do not allow arbitrary PHP execution, this package provides a Twig extension that exposes them as Twig functions.

If you're using Twig with Symfony2, you can load the extension from your config.yml:

    appneta.twig.traceview_twig_rum_extension:
        class: AppNeta\TraceViewTwig\Extension\TraceViewRUMExtension
        tags:
            - { name: twig.extension }

If you're manually constructing a Twig environment, you should instead call the addExtension method directly:

$twigEnv = new Twig_Environment($loader, $options);

$twigEnv->addExtension(new AppNeta\TraceViewTwig\Extension\TraceViewRUMExtension);

For full details on placing these snippets, please see this knowledge base article. Here is a basic example:

<html>
  <head>
    <meta ... >
    {{ oboe_get_rum_header() }}
  </head>

  <body>
    ...
    {{ oboe_get_rum_footer() }}
  </body>
</html>

Note: these functions only accept one argument: whether to output <script> tags around the snippet (defaults to true).

The best place to put these functions is in your root Twig layout template (such as TwigBundle::layout.html.twig). It is possible to use these Twig functions in a block, like javascript or body, but there are two downsides: you may inadvertantly output the script tags more than once per HTML document, and the timing information will be less accurate if the JavaScript gets loaded after other JavaScript or CSS stylesheets.

Contributors

Thanks to Willem van der Jagt of Cakemail for writing the initial integration between TraceView RUM and Twig!

Contributing

The best way to improve this package is to work with the people using it! We actively encourage patches, pull requests, feature requests, and bug reports.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 43
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-10-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固