承接 audunru/version-warning 相关项目开发

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

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

audunru/version-warning

Composer 安装命令:

composer require audunru/version-warning

包简介

Warn SPA users when they are using an outdated client

关键字:

README 文档

README

Build Status Coverage Status

Laravel middleware to help you notify users who are using an outdated version of the SPA client.

When you deploy a new version of your SPA to your server, not all users will start using the new version immediately. Anyone who is already logged in and does not refresh the page, will continue to use the old client until they close the browser tab or refresh the page. This package is meant to help you notify users with an outdated client that they should reload in order to use the latest version.

Currently, the package gets its version info from a package.json file in the root folder. This means that you will have to update the version in the package.json file whenever you make a change that requires all clients to update.

Installation

Step 1: Install with Composer

composer require audunru/version-warning

Step 2: Add middleware to your routes

Add the VersionWarning middleware to your API routes:

'api' => [
    'throttle:api',
    \Illuminate\Routing\Middleware\SubstituteBindings::class,
    \audunru\VersionWarning\Middleware\VersionWarning::class,
],

Step 3: Notify user when client is outdated

Alternative A: Compare X-App-Version header client side

When you make a fetch request to the server, add a X-App-Version header with a value of the client's current version. E.g.: X-App-Version: 1.18.1.

The VersionWarning middleware will compare the client version to the server version, and add a header called X-Version-Warning to the response if the versions do not match.

On the client side, you should check for the presence of the X-Version-Warning header. If it is present, the user should be notified that a reload is necessary so that the latest client assets (JavaScript and CSS) can be loaded.

Alternative B: Compare X-App-Version header client side

The VersionWarning middleware adds a header called X-App-Version to the response. On the client side, you can compare this version to the client version and notify the user in case of a mismatch.

Which version is the client running?

Set client version during build

If you're using Laravel Mix, you can include the current version during build time.

Set the MIX_VERSION environment variable in your build script (you should install the cross-var and cross-env packages so that this works on both Mac/Windows):

"production": "cross-var cross-env MIX_VERSION=$npm_package_version mix --production",

You can then use process.env.MIX_VERSION in your frontend code.

Get client version from HTML meta tag

Add the following to your layout blade template:

<meta name="app-version" content="{{ app_version() }}" />

In your frontend code, read the value of this meta tag.

Configuration

Publish the configuration file by running:

php artisan vendor:publish --tag=version-warning-config

Development

Testing

Run tests:

composer test

audunru/version-warning 适用场景与选型建议

audunru/version-warning 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.09k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 11 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 audunru/version-warning 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-11-28