jricardolima/ci4-lit-rollup 问题修复 & 功能扩展

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

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

jricardolima/ci4-lit-rollup

Composer 安装命令:

composer require jricardolima/ci4-lit-rollup

包简介

Integration between CI4 + LIT + ROLLUP

README 文档

README

A clean and opinionated integration of Lit + Rollup + TypeScript for CodeIgniter 4.6+ projects.

This package provides a modern frontend workflow without introducing SPA complexity, keeping full control over the build and production output.

✨ Features

  • ⚡ Rollup preconfigured out of the box
  • 🧩 Lit (Web Components) with TypeScript
  • 📦 Automatic manifest generation (cache busting)
  • 🛠️ spark commands for init, build and dev
  • 🧠 Native CI4 helper: frontend_script()
  • 🚫 No Node.js running in production

📦 Installation

Install via Composer and initialize the frontend:

composer require jricardolima/ci4-lit-rollup
php spark frontend:init
php spark frontend:install
php spark frontend:build
php spark frontend:dev

🤔 Why not Vite?

Vite is great — for SPAs.

This package intentionally avoids Vite because:

  • Most CI4 projects are server-rendered, not SPAs

  • Running a dev server + HMR is unnecessary overhead

  • Production does not need Node.js at all

  • Rollup gives full control over output structure

  • Manifest-based loading is predictable and stable

  • Fewer abstractions, fewer surprises

If you need a full SPA, Vite is an excellent choice. If you want modern JavaScript without turning your CI4 app into a SPA, this package is built for you.

📌 Design philosophy

  • Build happens only in development

  • Production serves static assets only

  • No framework lock-in

  • Explicit over magic

Ideal for:

  • ERPs

  • Internal systems

  • CI4-based SaaS

  • Projects that want modern frontend without SPA complexity

🧩 Why Lit?

Lit is a modern library built on top of Web Components, not a framework that replaces the platform.

It was chosen for this package because it is:

  • Standards-based
    Built directly on Web Components, Custom Elements and Shadow DOM.

  • Lightweight
    Minimal runtime, fast startup, small bundles.

  • Framework-agnostic
    Works perfectly with server-rendered applications like CI4.

  • Simple by design
    Low API surface, easy to reason about, no complex lifecycle.

  • Future-proof
    Web Components are a browser standard, not a transient abstraction.

Lit allows you to build reusable UI components without turning your application into a SPA, making it a natural fit for CodeIgniter-based projects.

🧩 Enabling the Helper

After installing and running frontend:init, you must load the helper so CodeIgniter can resolve frontend_script().

The recommended approach is to load it globally in your BaseController:

namespace App\Controllers;

use CodeIgniter\Controller;

class BaseController extends Controller
{
     public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
    {
        // Load here all helpers you want to be available in your controllers that extend BaseController.
        // Caution: Do not put the this below the parent::initController() call below.
        $this->helpers = ['form', 'url','frontend'];

        // Caution: Do not edit this line.
        parent::initController($request, $response, $logger);

        // Preload any models, libraries, etc, here.
        // $this->session = service('session');
    }
}

🖼️ Loading the frontend assets in views

<?= frontend_script() ?>

✅ Best practice: Place this call in your main layout view (for example app/Views/layouts/default.php), so all child views automatically load the frontend assets.

🔄 Updating

After updating the package via Composer:

composer update jricardolima/ci4-lit-rollup

Run the init command again to generate any new files:

php spark frontend:init

⚠️ Existing configuration files will NOT be overwritten. If a new version introduces changes to configs or scripts, please check the CHANGELOG for manual steps.

📄 License

MIT

jricardolima/ci4-lit-rollup 适用场景与选型建议

jricardolima/ci4-lit-rollup 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 12 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 jricardolima/ci4-lit-rollup 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-17