inventor96/inertia-offline-mako
Composer 安装命令:
composer require inventor96/inertia-offline-mako
包简介
Mako framework adapter for inventor96/inertia-offline.
README 文档
README
A Mako framework adapter for inertia-offline, enabling offline-first capabilities for Inertia.js applications.
Beta: offline read-only layer for Inertia.js apps, focused on safe cached content and navigation fallback.
This PHP backend package is designed to work with inertia-offline (the JS/TS frontend service worker library). Both the frontend and the backend aspects are required for an Inertia.js app.
Installation
1. Install via Composer
composer require inventor96/inertia-offline-mako
2. Register the Package in Mako
Add the package to your app/config/application.php:
'packages' => [ 'web' => [ inventor96\InertiaOfflineMako\InertiaOfflinePackage::class, ], ],
Usage
See inertia-offline for usage instructions on how to mark routes as offline-cacheable and configure the client-side service worker.
Configuration
The default configuration for the package works out of the box, but you can create an override file at app/config/packages/inertia-offline/offline.php to customize settings:
return [ /** * The class that implements `PaginationUrlExpanderInterface` to use for * expanding pagination URLs in the `OfflineRoutes` adapter. When left null * or empty, the default is to use an adapter that relies on the built-in * pagination of Mako. */ 'pagination_expander' => null, /** * The time (in seconds) that the offline route list response should be * cached by clients and intermediate caches. Default is 86400 (24 hours). */ 'route_list_cache_ttl' => 86400, /** * The path for the route that serves the list of offline routes. Must be * the same as `routeMetaPath` in the client config. Set to null or empty * to disable automatic registration of the route (e.g. you want to * register it manually). Default is `/pwa/offline-routes`. */ 'routes_path' => '/pwa/offline-routes', /** * The path for the route that serves the Inertia version. Must be the same * as `routeVersionPath` in the client config. Set to null or empty to * disable automatic registration of the route (e.g. you want to register * it manually). Default is `/pwa/offline-version`. */ 'version_path' => '/pwa/offline-version', ];
Etag Middleware
In case you don't have Etag support in your application, you can use the ConditionalEtag middleware provided by the package. This middleware generates ETags for responses related to offline functionality. Enabling ETag support is optional, but is highly recommended for better caching and performance for the client-side service worker.
Register Globally
As the middleware automatically avoids adding ETags to non-offline responses, you can safely register it globally. Add the middleware to your app/http/routing/middleware.php in the global middleware list, setting a high priority to ensure it runs last:
$dispatcher ->registerGlobalMiddleware(\inventor96\InertiaOfflineMako\ConditionalEtag::class) ->setMiddlewarePriority(\inventor96\InertiaOfflineMako\ConditionalEtag::class, 1000);
Custom Pagination URL Expander
By default, the package uses Mako's built-in pagination. If your application uses custom pagination patterns, implement a custom expander.
Example Implementation
Create a class that implements PaginationUrlExpanderInterface:
<?php namespace app\adapters; use inventor96\InertiaOffline\Contracts\PaginationUrlExpanderInterface; use inventor96\InertiaOffline\OfflineCacheable; class CustomPaginationUrlExpander implements PaginationUrlExpanderInterface { public function expand( string $baseUrl, mixed $pagination, // from the OfflineCacheable::$pagination attribute mixed $route, OfflineCacheable $attribute, array $routeParams = [] ): array { $urls = []; // Extract total pages or items from your pagination object $totalPages = $pagination->pages() ?? 1; // Generate URLs for each page for ($page = 1; $page <= $totalPages; $page++) { $urls[] = $baseUrl . '?page=' . $page; } return $urls; } }
Register in Config
Update app/config/packages/inertia-offline/offline.php to use your custom expander:
'pagination_expander' => \app\adapters\CustomPaginationUrlExpander::class,
The package will automatically instantiate your expander through the Mako framework container and use it when generating offline route lists.
inventor96/inertia-offline-mako 适用场景与选型建议
inventor96/inertia-offline-mako 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「mako」 「offline」 「inertia」 「service worker」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 inventor96/inertia-offline-mako 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 inventor96/inertia-offline-mako 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 inventor96/inertia-offline-mako 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Rich payment solutions for Laravel framework. Paypal, payex, authorize.net, be2bill, omnipay, recurring paymens, instant notifications and many more
Generate routes based on OpenAPI specifications and OpenAPI specifications from code
A debug toolbar for the Mako Framework
A REPL for the Mako Framework
Set Facebook offline conversion
Rich payment solutions for Yii framework. Paypal, payex, authorize.net, be2bill, omnipay, recurring paymens, instant notifications and many more
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 28
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-03