Atitit. how to use the engine and script architecture design? Use php and js to develop the desktop program Atitit. use the engine and script architecture design to use php and js to develop desktop programs ..
1. engine and script architecture cross-platform, desktop and web advantages 1
2. Architecture Desktop Engine (java, c #) 2
3. key points of the php Desktop Engine 2
3.1. running environment: supports both cs desktop and web 2
3.2. html5 + css + js implementation 2
3.3. Cli interface interoperability, and web Interface Interoperability 2
3.4. other ---------- process 2
3.4.1. check if some background Engines $ parser = php c # java js2 are available on the Html5 interface.
3.4.2. desktop engine dispatch3
3.4.3. use the cli engine to forward data to php3
3.4.4. phprun. bat4
3.4.5. Php also supports parameter transfer between web and desktop 4
3.4.6. resolve the $ _ GET parameter of the desktop program, and customize req Engine 4
3.4.7. callback js through $ callback5
4. FAQs and recent practices 5
4.1. use cmd.exe or direct bat .. 5
5. other php desktop programs 6
6. refer to 6
1. cross-platform engine and script architecture, desktop and web advantages
Cross-platform java is good. But java needs to be compiled .. If you need a desktop program, you need to modify it flexibly. you can write it as a script, and you can consider the engine and script architecture... Use php or js for desktop backend...
Author: old Wow's paw Attilax iron, EMAIL: 1466519819@qq.com
2. Architecture Desktop Engine (java, c #)
3. php Desktop Engine points 3.1. running environment: supports both cs desktop and web 3.2. the interface uses html5 + css + js to implement 3.3. cli interface interoperability, and web Interface Interoperability 3.4. other ---------- process 3.4.1. the Html5 interface determines if some background Engines $ parser = php c # java js
Use the dwr engine to convert to http param ..
It is best to have a general configuration of the engine to use, or you can configure different engines on a separate page ..
3.4.2. desktop engine dispatch
Proj. amazon splider
// For JS calls
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(paramsxcmd.exe c (). 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. use the cli engine to forward data to 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 "+ pathx. startupPath () + "/com. attilax/api. php @ 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 also supports parameter transfer between web and desktop
/Com. attilax/api. php @ qut "+ urlparams +" @ qut ";
Web api. php? Urlparams ....
3.4.6. resolve the $ _ GET parameter of the desktop program and customize the req engine
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"] = $;
$ 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. callback js uses $ 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. FAQs and recent practices 4.1. use cmd.exe or direct bat ..
The bat method is recommended .. VNC cmd.exe
String cmd = "@ qut" + pathx. startupPath () + "/phprun. bat @ qut "+ pathx. startupPath () + "/com. attilax/api. php @ qut "+ urlparams +" @ qut ";
Cmd = cmd. Replace ("@ qut ","\"");
The correct method is to add all characters after/C with double quotation marks:
Comparing the two commands, many people will immediately understand why.
This is because there are two commands and they are nested. the external commands are:
Cmd.exe/C "command"
The command is cmd.exe, and the two parameters are/C and "command". here the command is
5. other php desktop programs
Php gtk
WinBinder
6. Reference
Use PHP to develop desktop applications. html
When CMD is executed, the parameter is enclosed by quotation marks. Frequently Asked Questions-mi-Moshi's Blog-Blog channel-CSDN.NET.html
C # run the doscommand (CMD command)-Yang Youshan-blog channel-CSDN. NET
Paip. asp vbs call PHP code through CLI-attilax column-blog channel-CSDN. NET
Paip. run shell cmd command uapi java php python summary-attilax column-blog channel-CSDN. NET