Atitit.使用引擎加脚本架构的设计?使用php,js来开发桌面程序
Atitit.使用引擎加脚本架构的设计 使用php,js来开发桌面程序。。
1. 引擎加脚本架构 跨平台,桌面与web的优势1
2. 架构桌面引擎(java,c#)2
3. php桌面引擎要点2
3.1. 运行环境:同时支持cs桌面与web方式2
3.2. 界面使用html5+css+js实现2
3.3. Cli接口互操作,与web接口互操作2
3.4. 其他----------流程2
3.4.1. Html5界面确定要是有的后台引擎$parser=php c# java js2
3.4.2. 桌面引擎dispatch3
3.4.3. 使用cli引擎转发到php3
3.4.4. phprun.bat4
3.4.5. Php同时支持web与桌面的参数传递4
3.4.6. 桌面程序$_GET参数的解析,自定义req引擎4
3.4.7. 回调js 通过$callback5
4. 常见问题与最近实践5
4.1. 使用cmd.exe还是直接bat。。5
5. 其他的php桌面程序方案6
6. 参考6
1. 引擎加脚本架构 跨平台,桌面与web的优势
跨平台方面java很不错。但是java需要编译。。如果需要一个桌面程序,需要灵活修改,可以脚本写成的化,就可以考虑引擎加脚本架构 。。。使用php或者js来做桌面后端。。。
作者:: 老哇的爪子 Attilax 艾龙, EMAIL:1466519819@qq.com
2. 架构桌面引擎(java,c#)
3. php桌面引擎要点
3.1. 运行环境:同时支持cs桌面与web方式
3.2. 界面使用html5+css+js实现
3.3. Cli接口互操作,与web接口互操作
3.4. 其他----------流程
3.4.1. Html5界面确定要是有的后台引擎$parser=php c# java js
使用dwr引擎转换为http param..
最好可以有个总配置要使用什么引擎,也可以单独页面配置不同的引擎。。
3.4.2. 桌面引擎dispatch
Proj.amazon splider
//供JS调用
public void sendNSCommand(Object message, Object message2, Object message3, Object message4, Object message5, Object message6, Object message7)
{
// Object[] objs = (Object[])message;
Console.WriteLine(message);
String meth =(String) message;
//p822
string paramsx=((string) message2);
if (paramsx.Contains("$parser"))
{
String r = new php?ParesrX(paramsx).exec().Trim() ;
Map m = new ParamX().urlParams2Map((string)message2);
String callback = (String)m.get("$callback");
String js2 = callback + "('" + r + "');";
WebBrowser webBrowser1 = (WebBrowser)iocx.getBean("webBrowser1");
object[] objects = new object[1];
objects[0] = r;
Object o = webBrowser1.Document.InvokeScript(callback, objects);
Console.WriteLine("==exe js rzt:" + o);
return;
}
3.4.3. 使用cli引擎转发到php
class ParesrX
{
private string meth;
public ParesrX(string meth)
{
// TODO: Complete member initialization
this.meth = meth;
}
internal String exec()
{
Map m =new ParamX().urlParams2Map(this.meth);
if (((String)m.get("$parser")).Equals("php"))
{
String urlparams = m.serialize();
String cmd = "@qut" + pathx.StartupPath() + "/phprun.bat@qut @qut" + pathx.StartupPath() + "/com.attilax/api.php@qut @qut" + urlparams + "@qut";
cmd=cmd.Replace("@qut","\"");
Console.WriteLine(cmd);
String r= new Cmd().RunCmd(cmd);
return r;
}
return "";
3.4.4. phprun.bat
@d:
@"%~dp0php5.3.10\php.exe" -c "%~dp0php5.3.10\php.ini" -f %1 %2 %3
3.4.5. Php同时支持web与桌面的参数传递
/com.attilax/api.php@qut @qut" + urlparams + "@qut";
Web方式 api.php?urlparams....
3.4.6. 桌面程序$_GET参数的解析,自定义req引擎
if(count($_GET)==0) //cli mode
{
$param=$argv[1];
$GLOBALS["varx"]["argv"]=$argv ;
$_GET=urlParams2Map($param);
$GLOBALS["varx"]["get"]=$_GET ;
}
function urlParams2Map( $params) {
$o=array();
$a=explode('&',$params);
$GLOBALS["varx"]["a"]=$a ;
$GLOBALS["varx"]["params"]=$params;
foreach( $a as $k2=>$v2 )
{
$a2=explode("=",$v2);
$k=$a2[0];
$v=$a2[1];
$o[$k]=$v;
}
$GLOBALS["varx"]["o"]=$o ;
return $o;
}
3.4.7. 回调js 通过$callback
String callback = (String)m.get("$callback");
String js2 = callback + "('" + r + "');";
WebBrowser webBrowser1 = (WebBrowser)iocx.getBean("webBrowser1");
object[] objects = new object[1];
objects[0] = r;
Object o = webBrowser1.Document.InvokeScript(callback, objects);
4. 常见问题与最近实践
4.1. 使用cmd.exe还是直接bat。。
推荐使用bat方式。。否则cmd.exe
String cmd = "@qut" + pathx.StartupPath() + "/phprun.bat@qut @qut" + pathx.StartupPath() + "/com.attilax/api.php@qut @qut" + urlparams + "@qut";
cmd=cmd.Replace("@qut","\"");
正确的方式是,将 /C 后面所有字符,再加上双引号:
对比两段命令,很多人马上就明白为什么了。
因为,这里相当于有两条命令,并且是嵌套的,外面的命令是:
cmd.exe /C "command"
命令是 cmd.exe,两个参数分别是 /C, "command",我们这里的 command 是
5. 其他的php桌面程序方案
php gtk
WinBinder
6. 参考
用PHP开发桌面应用.html
执行 CMD 时,参数加引号常见问题 - 的米-漠石's Blog - 博客频道 - CSDN.NET.html
C#执行DOS命令(CMD命令) - 杨友山 - 博客频道 - CSDN.NET
paip.asp vbs通过CLI命令行调用PHP代码 - attilax的专栏 - 博客频道 - CSDN.NET
paip.执行shell cmd 命令uapi java php python总结 - attilax的专栏 - 博客频道 - CSDN.NET

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.
