jensroland/chain-lightning
Composer 安装命令:
composer require jensroland/chain-lightning
包简介
Parallel dependency loading for ES modules with intelligent caching
README 文档
README
PHP server adapter for Chain Lightning - cache-efficient parallel dependency loading for ES modules.
Installation
composer require jensroland/chain-lightning
Quick Start
<?php use ChainLightning\ChainLightning; $cl = new ChainLightning('./dist/.chain-lightning/manifest.json', $_SERVER['HTTP_USER_AGENT'] ?? ''); ?> <!DOCTYPE html> <html> <head> <?= $cl->headScripts() ?> </head> <body> <?= $cl->component('search-component') ?> <search-component></search-component> </body> </html>
Integration with Skybolt
Chain Lightning works best with Skybolt for optimal caching:
<?php use Skybolt\Skybolt; use ChainLightning\ChainLightning; // Skybolt handles CSS and Service Worker caching $sb = new Skybolt('./dist/.skybolt/render-map.json'); // Chain Lightning uses Skybolt for cache-aware decisions $cl = new ChainLightning('./dist/.chain-lightning/manifest.json', $_SERVER['HTTP_USER_AGENT'] ?? '', $sb); ?> <!DOCTYPE html> <html> <head> <?= $sb->css('src/css/main.css') ?> <?= $sb->launchScript() ?> <?= $cl->headScripts() ?> </head> <body> <?= $cl->component('search-component', inlineDeps: true) ?> <search-component></search-component> </body> </html>
When integrated with Skybolt:
- First visit: Chunk dependencies are inlined via data URLs
- Repeat visits: Dependencies are loaded from Service Worker cache (~5ms)
API Reference
use ChainLightning\ChainLightning; $cl = new ChainLightning($manifestPath, $userAgent = '', $skyboltInstance = null); // Convenience method - renders all head scripts $cl->headScripts(); // Individual head scripts (if you need more control) $cl->importMap(); // Render <script type="importmap"> $cl->manifestScript(); // Render manifest data script $cl->clientScript(); // Render client runtime script // Render component with preloads $cl->component('name'); $cl->component('name', inlineDeps: true); // Inline chunk deps on first visit // Utility methods $cl->getComponentUrl('name'); // Get component URL $cl->getModuleUrl('specifier'); // Get module URL from import map $cl->getManifest(); // Get raw manifest data // HTTP 103 Early Hints $hints = $cl->getEarlyHints(['comp1', 'comp2']); foreach ($hints as $hint) { header("Link: <{$hint['href']}>; rel={$hint['rel']}; as={$hint['as']}", false); }
Requirements
- PHP 8.1+
- Vite build with
@skybolt/chain-lightningplugin
Vite Configuration
// vite.config.js import { defineConfig } from 'vite' import { chainLightning } from '@skybolt/chain-lightning/vite' export default defineConfig({ build: { manifest: true, rollupOptions: { input: { 'search-component': 'src/components/search-component.js', 'counter-component': 'src/components/counter-component.js' } } }, plugins: [ chainLightning({ components: ['search-component', 'counter-component'] }) ] })
How It Works
See the main Chain Lightning documentation for details on:
- The waterfall problem Chain Lightning solves
- Build-time dependency analysis
- Import map generation
- Versioning strategy
License
MIT
jensroland/chain-lightning 适用场景与选型建议
jensroland/chain-lightning 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「performance」 「cache」 「modules」 「preload」 「esm」 「import-map」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jensroland/chain-lightning 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jensroland/chain-lightning 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jensroland/chain-lightning 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This is Paymorrow module for OXID eShop.
g4 application profiler package
repository php library
CSS/Javascript Minificator, Compressor and Concatenator for TYPO3 - highly configurable frontend asset optimization for CSS/JS merging, minification and compression with optional body parsing, async/defer loading, inline output, data-ignore exclusions, SRI integrity validation/calculation, external
WordPress mu-plugin to remove jQuery Migrate from the list of jQuery dependencies and to allow jQuery to enqueue before </body> instead of in the <head>.
Create link to static resources with cache-breaking segment based on md5 of the file
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 29
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-01