kingbes/webui

webui 绑定 php 实现跨平台桌面应用

v0.0.4 2024-08-27 07:07 UTC

This package is auto-updated.

Last update: 2024-09-27 07:40:10 UTC


README

Logo

PHP 的 WebUI

使用任何网络浏览器或 WebView 作为 GUI,后端使用您喜欢的语言,前端使用现代网络技术,所有这些都包含在一个轻量级便携库中。

Screenshot

中文自述

WebView 在 win32 上可能无法工作

composer

composer require kingbes/webui

示例

  1. 示例一

index.html

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- You must add webu.js; otherwise, the interaction cannot be performed -->
    <script src="webui.js"></script>
</head>

<body>
    <button onclick="btn()">asd</button>
    <script>
        function btn() {
            hello('hello').then(function (res) {
                console.log(res)
            })
        }
    </script>
</body>

</html>

index.php

require "./vendor/autoload.php";

use Kingbes\Webui;
use Kingbes\JavaScript;

$Webui = new Webui;
$html = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . "index.html");
$window = $Webui->newWindow();
$bind = $Webui->bind($window, "hello", function ($event, JavaScript $js) {
    // Gets the first argument as a string
    $arg_one = $js->getString($event);
    var_dump($arg_one);

    // return string
    $js->returnString($event, "nihao");
});
$Webui->show($window, $html);
$Webui->wait();
$Webui->clean();

各类用法说明

  1. Webui Webui 类
  2. JavaScript 用于与 js 绑定交互
  3. Wrapper 包装整个交互的包装器等
  4. Cobj 包装器,用于包装与其他 C 对象类的整个交互,可能需要一些函数

MORE

网站