blueweb/nette-ajax-history 问题修复 & 功能扩展

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

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

blueweb/nette-ajax-history

Composer 安装命令:

composer require blueweb/nette-ajax-history

包简介

Adds History API support for Nette Framework 3.2+ (readonly Application).

README 文档

README

Adds History API support to nette.ajax.js addon for Nette Framework!

This repo is a fork of vojtech-dobes/history.nette.ajax.js package with additional support for Nette 3.

All credits go to Vojtěch. Thank you!

Compatibility

Package version Nette
^4.0 nette/application 3.2+ (readonly Application), nette/http 3.3+, PHP 8.2+
^3.0 Nette 3.0 – 3.1

4.0.0 is a compatibility release for the readonly Application era. Since nette/application 3.2 the Application::$httpRequest property is a promoted readonly property, so the previous reflection-based request swapping no longer works. The redirect re-run now uses the public Application::processRequest() API and is wrapped in the same lifecycle as Application::run() (onStartup / onShutdown, and onError on failure) so it behaves consistently with a normal request.

Note: because the redirect re-run fires onStartup / onShutdown again within the same HTTP request, handlers bound to these events must be idempotent (this was already the case with the previous run()-based implementation).

Installation

  1. Link client-side/history.ajax.js after nette.ajax.js.
  2. Load PHP files with Composer: blueweb/nette-ajax-history
  3. Register config extension in your configuration:
extensions:
	ajaxHistory: Blueweb\NetteAjax\HistoryExtension

Usage

Write your application as normal. All redirects and forwards will be properly handled.

To correctly update UI, use snippets. If you plan to ajaxify whole application, consider adding this snippet to your beforeRender() method in BasePresenter.

if ($this->isAjax()) {
	$this->invalidateControl('title');
	$this->invalidateControl('content');
}

And app/@layout.latte might be upgraded accordingly:

<title n:inner-snippet="title">...</title>
{snippet content}
	{include content}
{/snippet}

Disabling

If you want specific links or forms exclude from scope of this addon (not make them update the URL), you can use data-ajax-off feature of nette.ajax.js.

<a class="ajax" data-ajax-off="history">

UI Caching

Extension will automatically cache your UI and restore it on Back and Forward buttons without communication with server. If you wish to call server on every Back and Forward, turn caching off.

$.nette.ext('history').cache = false;

Changelog

4.0.0

  • BREAKING: requires nette/application 3.2+ (readonly Application). Not compatible with Nette < 3.2.
  • Replaced reflection-based Application::$httpRequest swapping with the public Application::processRequest() API (the property is now readonly and cannot be mutated).
  • Redirect re-run is wrapped in the same lifecycle events as Application::run() (onStartup / onShutdown, onError on failure).
  • Fixed Nette\Http\Request construction for nette/http 3.3 (non-nullable array / string constructor arguments).
  • Declared previously transitive dependencies explicitly: nette/routing, nette/utils.
  • Removed the legacy Nette 2.x Nette\Config\CompilerExtension class alias.

blueweb/nette-ajax-history 适用场景与选型建议

blueweb/nette-ajax-history 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 42.47k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 03 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 blueweb/nette-ajax-history 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-03-21