webman-desktop跨平台桌面应用开发分享

KingBes

可能之前发布的php-webview桌面开发,对于习惯了mvc模式的人来说还是有点不太习惯
下面就发布一个套壳版的:谷歌内核,还是很轻量级的,而且跨平台~

点击下载

执行文件

windows系统为:windows.exe

linux系统为:linux

配置文件 config.json

{
    "windows":{
        "icon":"./favicon.ico", // 图标
        "title":"php-desktop", // 窗口标题
        "width":600, // 窗口宽度
        "height":400, // 窗口高度
        "hint":"auto", // 窗口大小 auto:自动 min:固定最小 max:固定最大 fixed:固定大小 
        "debug":false // debug模式
    },
    "php":{
        "file":"./php/windows/php.exe", // 执行文件
        "address":"127.0.0.1", // url地址
        "port":"*", // 端口号 *:随机端口 其他:固定端口号
        "entrance":"./www/route.php", // 执行路由
        // php -S 127.0.0.1:8080 route.php 开启php内置web
        "is_custom_instruction":false, // 是否开启自定义命令 true:就不按照开启php内置web来执行
        "start_instruction":"", // 开启命令
        "stop_instruction":"", // 结束命令
        "auto_stop":true // 关闭窗口时是否自动关闭php,若为false则需要填写 结束命令 来关闭
    }
}

windows 配置

webman框架

{
    "windows":{
        "icon":"./favicon.ico", // 图标
        "title":"php-desktop", // 窗口标题
        "width":600, // 窗口宽度
        "height":400, // 窗口高度
        "hint":"auto", // 窗口大小 auto:自动 min:固定最小 max:固定最大 fixed:固定大小 
        "debug":false // debug模式
    },
    "php":{
        "file":"./php/windows/php.exe", // 执行文件
        "address":"127.0.0.1", // url地址
        "port":"8787", // 必须-固定端口号
        "entrance":"", //不用填
        "is_custom_instruction":true, // 开启
        "start_instruction":"./webman/start.php", // 开启命令
        "stop_instruction":"", // win系统不用填
        "auto_stop":true // 必须为true
    }
}

其他框架

{
    "windows":{
        "icon":"./favicon.ico", // 图标
        "title":"php-desktop", // 窗口标题
        "width":600, // 窗口宽度
        "height":400, // 窗口高度
        "hint":"auto", // 窗口大小 auto:自动 min:固定最小 max:固定最大 fixed:固定大小 
        "debug":false // debug模式
    },
    "php":{
        "file":"./php/windows/php.exe", // 执行文件
        "address":"127.0.0.1", // url地址
        "port":"*", // 端口号 *:随机端口 其他:固定端口号
        "entrance":"./www/route.php", // 执行路由文件,具体参考route.php文件内容
        // php -S 127.0.0.1:8080 route.php 开启php内置web
        "is_custom_instruction":false, // 必须为false
        "start_instruction":"", // 不用填
        "stop_instruction":"", // 不用填
        "auto_stop":true // 必须为true
    }
}

linux 配置

webman框架

{
    "windows":{
        "icon":"./favicon.ico", // 图标
        "title":"php-desktop", // 窗口标题
        "width":600, // 窗口宽度
        "height":400, // 窗口高度
        "hint":"auto", // 窗口大小 auto:自动 min:固定最小 max:固定最大 fixed:固定大小 
        "debug":false // debug模式
    },
    "php":{
        "file":"./php/linux/php", // 执行文件
        "address":"127.0.0.1", // url地址
        "port":"8787", // 必须-固定端口号
        "entrance":"", //不用填
        "is_custom_instruction":true, // 开启
        "start_instruction":"./webman/start.php start -d", // 开启命令
        "stop_instruction":"./php/windows/php.exe ./webman/start.php stop", // 结束命令
        "auto_stop":false // false
    }
}

其他框架

{
    "windows":{
        "icon":"./favicon.ico", // 图标
        "title":"php-desktop", // 窗口标题
        "width":600, // 窗口宽度
        "height":400, // 窗口高度
        "hint":"auto", // 窗口大小 auto:自动 min:固定最小 max:固定最大 fixed:固定大小 
        "debug":false // debug模式
    },
    "php":{
        "file":"./php/linux/php", // 执行文件
        "address":"127.0.0.1", // url地址
        "port":"*", // 端口号 *:随机端口 其他:固定端口号
        "entrance":"./www/route.php", // 执行路由文件,具体参考route.php文件内容
        // php -S 127.0.0.1:8080 route.php 开启php内置web
        "is_custom_instruction":false, // 必须为false
        "start_instruction":"", // 不用填
        "stop_instruction":"", // 不用填
        "auto_stop":true // 必须为true
    }
}

接口

<button onclick="isMsg()">弹出消息框</button>
<button onclick="files()">打开文件框</button>
<button onclick="dirs()">打开文件夹</button>
<script>
    async function isMsg() {
        let msg = await win_alert("你好", 1)
        console.log(msg)
    }
    async function files() {
        let file = await win_file_dialog()
        console.log(file)
    }
    async function dirs() {
        let dir = await win_open_dir()
        console.log(dir)
    }
</script>

501 2 3
2个评论

掌柜

大佬,可以适配Mac的吗?

  • KingBes 2024-08-07

    我没有mac,没能编译到mac

  • 掌柜 2024-08-07

    好吧,这个是不是基于electron的吧?之前玩了一下electron打包一下就200多M,还体验了下tarui但是技术太菜,可惜不会rust只会做做页面。

  • KingBes 2024-08-08

    基于webview,基础包才1M不到,我用vlang编译的

misyuan

这个php版本可以自己换吗还是只能是固定的

KingBes

1400
积分
0
获赞数
0
粉丝数
2023-06-12 加入
×
🔝