定制 impulsephp/js 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

impulsephp/js

最新稳定版本:v1.0.0-beta

Composer 安装命令:

composer require impulsephp/js

包简介

JS engine for ImpulsePHP components

README 文档

README

Impulses is the official JavaScript engine for the ImpulsePHP framework. It adds dynamic behaviour to server rendered PHP components without any external dependency or JavaScript framework.

🚀 Features

  • ⚡ Automatic DOM handling through data-action-* attributes
  • 🔁 Partial updates via AJAX
  • 🧠 Two way binding between PHP components and the DOM
  • 📡 Dynamic action calls (data-action-click, data-action-submit, ...)
  • ♻️ Smart diffing to minimise reloads
  • 🧩 Extremely simple to use: a single <script> tag

🔧 Using in an ImpulsePHP project

Simply include the script in your layout or HTML page:

<script src="/assets/impulses/dist/impulse.js" type="module"></script>

🛠 Development

To build continuously during development:

npm run watch

Listening to localStorage changes

Impulses dispatches an impulse-localstorage event whenever localStorage is modified (including from other tabs). Subscribe to this event to update your components in real time:

window.addEventListener('impulse-localstorage', (e) => {
  const { key, value } = e.detail;
  console.log('Storage key changed:', key, value);
});

Documentation

Detailed guides for all features are available in the docs directory. This includes the router, event system, local storage synchronisation and interactions without JavaScript.

Running tests

Install dependencies and run:

npm test

DevTools (experimental)

A minimal development tool is included to inspect framework activity. Start the server:

node devtools/server.js

Then include dist/impulse.devtools.js in your page after impulse.js while developing:

<script src="/assets/impulses/dist/impulse.js" type="module"></script>
<script src="/assets/impulses/dist/impulse.devtools.js" type="module"></script>

Visit http://localhost:1337 to view events and network requests in real time.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: TypeScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-03