Atitit. Using the engine and scripting architecture design? Using PHP,JS to develop desktop programs

Source: Internet
Author: User
Atitit. The design using the engine plus script architecture uses PHP,JS to develop desktop programs.

1. Engine Plus script architecture cross-platform, desktop and Web benefits 1

2. Architecture Desktop Engine (java,c#) 2

3. PHP Desktop Engine Essentials 2

3.1. Operating environment: Support CS Desktop and Web mode 2

3.2. Interface using HTML5+CSS+JS implementation 2

3.3. CLI interface interoperability, interoperability with web interfaces 2

3.4. Other----------Processes 2

3.4.1. HTML5 interface Determines if there is a background engine $parser=php C # java JS2

3.4.2. Desktop Engine Dispatch3

3.4.3. Forwarding to PHP3 using the CLI engine

3.4.4. phprun.bat4

3.4.5. PHP supports both Web and desktop parameter passing 4

3.4.6. Parsing of $_get parameters for desktop programs, customizing Req Engine 4

3.4.7. Callback JS via $callback5

4. Frequently asked questions and recent practices 5

4.1. Use cmd.exe or direct bat. 5

5. Other PHP Desktop program scenarios 6

6. Reference 6

1. Engine Plus script architecture cross-platform, desktop and web advantages

The cross-platform aspect of Java is pretty good. But Java needs to be compiled. If you need a desktop program, you need flexibility to modify, you can write the script, you can consider the engine plus script architecture ... Use PHP or JS to do desktop backend ...

Author:: Old Wow's paw Attilax Ayron, email:1466519819@qq.com

2. Architecture Desktop Engine (java,c#)

3. PHP Desktop Engine Essentials

3.1. Operating environment: Support CS Desktop and Web mode at the same time

3.2. Interface using HTML5+CSS+JS implementation

3.3. CLI interface interoperability, interoperability with web interfaces

3.4. Other----------processes

3.4.1. HTML5 interface Determines if there is a background engine $parser=php C # java JS

Use the DWR engine to convert to HTTP param.

It is best to have a general configuration of what engine to use, or separate pages to configure different engines.

3.4.2. Desktop Engine Dispatch

Proj.amazon Splider

For JS Call

public void Sendnscommand (object message, Object Message2, Object Message3, Object Message4, Object Message5, Object Messa Ge6, 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. Forwarding to PHP using the CLI engine

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 supports both Web and desktop parameter passing

/com.attilax/api.php@qut @qut "+ urlparams +" @qut ";

Web Mode api.php?urlparams ....

3.4.6. Parsing of $_get parameters for desktop programs, custom 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"]= $a;

$GLOBALS ["Varx"] ["params"]= $params;

foreach ($a as $k 2=> $v 2)

{

$a 2=explode ("=", $v 2);

$k = $a 2[0];

$v = $a 2[1];

$o [$k]= $v;

}

$GLOBALS ["Varx"] ["O"]= $o;

return $o;

}

3.4.7. Callback JS via $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. Frequently asked questions and recent practices

4.1. Use cmd.exe or direct bat.

It is recommended to use the Bat method. otherwise 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", "\" ");

The correct way is to have all the characters followed by/C, plus double quotes:

Comparing the two commands, many people immediately understand why.

Because, here is the equivalent of two commands, and is nested, the outside command is:

CMD.EXE/C "Command"

command is cmd.exe, two parameters are/C, "command", our command here is

5. Other PHP Desktop program scenarios

PHP GTK

Winbinder

6. Reference

Develop desktop apps with PHP. html

When executing CMD, the parameter quotes frequently asked questions-the M-Mo Stone's blog-Blog Channel-CSDN.NET.html

C # Execute DOS command (CMD command)-Yang Youshan-Blog channel-csdn.net

paip.asp VBS invokes PHP code via CLI command line-attilax column-Blog channel-csdn.net

Paip. Execute shell cmd command uapi java PHP python summary-attilax's Column-Blog channel-csdn.net

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.