Php desktop two instance with different URL

205 views
Skip to first unread message

thesoft...@gmail.com

unread,
Sep 12, 2014, 5:26:35 AM9/12/14
to phpde...@googlegroups.com
Hi...

First of all I would like to appreciate all the developers for this awesome work. Keep rocking like this.

I have downloaded the latest version of php desktop with chrome 31 for windows OS. when i execute the phpdesktop-chrome.exe file It's running great. I can tune up the path to start with using settings.json.

Now the part in which in which I have a problem is I want two .exe files say
phpdesktop-chrome1.exe and phpdesktop-chrome2.exe

On executing phpdesktop-chrome1.exe URL with path say localhost/index.html will open and on executing phpdesktop-chrome2.exe URL with path say localhost/admin/index.html will open

Also how can I make the setting for one instance of window only. Like only one window of phpdesktop-chrome1.exe can be opened at a time.

Will expect a quick solution from you guys.

Thanks And well Done.

Czarek Tomczak

unread,
Sep 12, 2014, 7:11:29 AM9/12/14
to
You didn't say how you launch these exe instances, so not sure if this will help, but you can pass command line arguments to exe and see these in php through $_ENV, see:
https://code.google.com/p/phpdesktop/wiki/CGIEnvironmentFromArgs

If you make a copy of exe and put them in the same directory, then they share the same settings.json file. You could overwrite the settings.json file before running the second exe and restore the old settings.json after it was launched. However I think that the most straightforward way is to just create two directories: phpdesktop/chrome1/ and phpdesktop/chrome2/ and make a copy of phpdesktop binaries in each of these. They will have different settings.json files, so you can set "single_instance_guid" to allow for only single instance for one of them.  You can share the same phpdesktop/www/ directory and the same php binaries by editing paths in  settings.json for each of them. The downside is that it takes x2 disk space to keep these two instances. But the size of your application installer should not grow as it is compressed using zip/7z/etc.

There is still issue of differentiating in php scripts which exe instance was launched, in a case when they share the same www/ directory. One way would be to set a different server port in settings.json for each instance, then in php you can check it using $_SERVER["SERVER_PORT"]. But this opens for port conflicts. A more reliable way, but in a kind of hack, would be to set different phpdesktop version string that is embedded in the executable. You can do it using ResourceHacker, instructions are provided on the KnowledgeBase wiki page. You can then check in php scripts for $_SERVER["PHPDESKTOP_VERSION"] which for example could be set to "31.61" for chrome1.exe and "31.62" for chrome2.exe.

When you can differentiate which instance is launched using one of the tips above, you can add a condition in index.php and do a redirect to "localhost/admin/".

There is also Issue 104 to add option in settings.json for setting environment variables. This could allow for passing options to php without the need of command line parameters:
https://code.google.com/p/phpdesktop/issues/detail?id=104

thesoft...@gmail.com

unread,
Sep 12, 2014, 9:41:14 AM9/12/14
to phpde...@googlegroups.com
Hi.

Thanks for your quick reply.

Program will be started when user clicks on the .exe file. just like any end user do..

I don't want to go command line, Yes your idea of making two separate installer and directory is the last option I will use but do you think there is any alternative approach for this.

By the way.. how can I assign two different setting.json if I Copy and paste. I am using windows.

Also how can I make only two instance to be opened, like

On executing phpdesktop-chrome1.exe URL with path say localhost/index.html will open and on executing phpdesktop-chrome2.exe URL with path say localhost/admin/index.html will open both with just one instance..

Open two different instance will solve my issue.. but both must be unique with regards from where it is opened.

Any help on this..

Czarek Tomczak

unread,
Sep 12, 2014, 10:20:29 AM9/12/14
to phpde...@googlegroups.com
You can do a redirect in index.php to the admin/ url. You can detect which instance it is running using the ways I've described. If that is too complicated, then just make two copies of the www/ directory, in both chrome1/ and chrome2/.

Just make two copies of phpdesktop-chrome-31.6-xxxx/ directory, use the original phpdesktop binaries zip, start with that and it should become straightforward.

The option for having only single application window instance is called "single_instance_guid", see the Settings wiki page.

thesoft...@gmail.com

unread,
Sep 12, 2014, 10:40:07 AM9/12/14
to phpde...@googlegroups.com
Hi.

I think for the time being I can create two directory and work it out with different port no. I think this will solve the problem for now.

If any issue will arise then will post in the forum.

Thanks for your time.

Reply all
Reply to author
Forward
0 new messages