定制 helthe/turbolinks 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

helthe/turbolinks

Composer 安装命令:

composer require helthe/turbolinks

包简介

Helthe Turbolinks Component

关键字:

README 文档

README

Helthe Turbolinks is a direct port of the rails turbolinks gem for projects using the Symfony HttpFoundation Component.

Versions

Current versions of the following gems are used:

  • turbolinks: v5.0.0

Performance

Turbolinks makes following links in your web application faster. Instead of letting the browser recompile the JavaScript and CSS between each page change, it keeps the current page instance alive and replaces only the body and the title in the head.

Performance improvements will vary depending on the amount of CSS and Javascript you are using. You can get up to a 2X increase when using a lot of Javascript and CSS. You can find the rails benchmarks here.

Installation

Using Composer

Manually

Add the following in your composer.json:

{
    "require": {
        // ...
        "helthe/turbolinks": "~4.0"
    }
}

Using the command line

$ composer require 'helthe/turbolinks=~4.0'

Usage

Using turbolinks requires both the usage of the javascript library and modifying the PHP response so that it can be properly processed by turbolinks.

PHP

There are multiple ways to decorate the PHP response for turbolinks.

Manually

You can manually decorate the response with the Turbolinksobject.

<?php
use Helthe\Component\Turbolinks\Turbolinks;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

// ...

$turbolinks = new Turbolinks();
$turbolinks->decorateResponse($request, $response);

Event Listeners

You can add an event listener to the dispatcher that is passed to the HttpKernel.

<?php
use Helthe\Component\Turbolinks\EventListener\TurbolinksListener;
use Helthe\Component\Turbolinks\Turbolinks;

// ...

// Symfony\Component\EventDispatcher\EventDispatcherInterface
$dispatcher->addSubscriber(new TurbolinksListener(new Turbolinks()));

Stack Middleware

You can decorate the response using the supplied Stack middleware.

<?php
use Helthe\Component\Turbolinks\StackTurbolinks;
use Helthe\Component\Turbolinks\Turbolinks;

// ...

$app = new StackTurbolinks($app, new Turbolinks());

Javascripts

Both the original coffeescript version and compiled version of each script are available for use.

Using turbolinks.js

To enable turbolinks, all you need to do is add the compiled turbolinks javascript to your layout in the <head>section.

Integrating turbolinks with another PHP project

The goal of the component is to offer a base package for integration with other PHP projects using the Symfony HttpFoundation or HttpKernel components.

You can do so by either using the supplied middleware that follows the Stack convention or by adding the supplied event listenter to the HttpKernel event dispatcher.

Instead of copying over the compiled javascripts to your projects, try to use your project tools to copy them over. You should always be able to fallback on the composer script hooks like post-install-cmd and post-update-cmd.

List of integrations

Compatibility

The turbolinks javascript is designed to work with any browser that fully supports pushState and all the related APIs. This includes Safari 6.0+ (but not Safari 5.1.x!), IE10, and latest Chromes and Firefoxes.

Do note that existing JavaScript libraries may not all be compatible with Turbolinks out of the box due to the change in instantiation cycle. You might very well have to modify them to work with Turbolinks' new set of events. For help with this, check out the Turbolinks Compatibility project.

Additional Resources

Please refer to the turbolinks project if you require additional information on the javascript libraries and their usage.

Bugs

For bugs or feature requests, please create an issue.

helthe/turbolinks 适用场景与选型建议

helthe/turbolinks 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 122.98k 次下载、GitHub Stars 达 110, 最近一次更新时间为 2013 年 12 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「turbolinks」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 helthe/turbolinks 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 helthe/turbolinks 我们能提供哪些服务?
定制开发 / 二次开发

基于 helthe/turbolinks 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 110
  • Watchers: 7
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-12-24