Awesome
<div align="center">WebUI for PHP
</div>Use any web browser or WebView as GUI, with your preferred language in the backend and modern web technologies in the frontend, all in a lightweight portable library.
WebView may not work in win32
composer
composer require kingbes/webui
require | |
---|---|
PHP | 8.1+ |
FFI | * |
Windows | true |
Linux | true |
MacOs | To be tested |
示例
- 示例一
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();
各类用法说明
Webui
Webui classJavaScript
Used to interact with js bindingsWrapper
Wrappers that wrap the entire interaction, etcCobj
Wrappers, which wrap the entire interaction with other C object classes, some functions may be required