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/onShutdownagain within the same HTTP request, handlers bound to these events must be idempotent (this was already the case with the previousrun()-based implementation).
Installation
- Link
client-side/history.ajax.jsafternette.ajax.js. - Load PHP files with Composer:
blueweb/nette-ajax-history - 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/application3.2+ (readonlyApplication). Not compatible with Nette < 3.2. - Replaced reflection-based
Application::$httpRequestswapping with the publicApplication::processRequest()API (the property is nowreadonlyand cannot be mutated). - Redirect re-run is wrapped in the same lifecycle events as
Application::run()(onStartup/onShutdown,onErroron failure). - Fixed
Nette\Http\Requestconstruction fornette/http3.3 (non-nullablearray/stringconstructor arguments). - Declared previously transitive dependencies explicitly:
nette/routing,nette/utils. - Removed the legacy Nette 2.x
Nette\Config\CompilerExtensionclass 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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 blueweb/nette-ajax-history 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Adds History API support for Nette Framework.
Selenium4 (WebDriver) driver for Mink framework
laravel middleware to allow ajax only calls
Sitemap crawler/generator. For the given URL it will return sitemap XML file with URLs and images.
Nette Framework adapter for I18n package
Build forms from schema
统计信息
- 总下载量: 42.47k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-03-21