Opening a PHP Desktop app to be accessible from the Internet when running

1,906 views
Skip to first unread message

Dallin

unread,
Feb 22, 2016, 6:12:38 PM2/22/16
to PHP Desktop
Hi!

I'm trying to use PHP Desktop to create a web service server that our customers can install on their computer. The main window just has a few options, shows that it's running, and minimizes to the system tray. Elsewhere in the project I have a RESTful web service in a PHP doc. 

In other words, I'm trying to create a way for our customers to install something on their computer, run it, and they've got a web server up with a php web service ready to consume. They don't have to have any knowledge of setting anything up other than installing and running the program. The web server then interacts with a database that a different software package we sell puts on their PC. I've always loved PHP Desktop and was hoping to use it for this task.

So far it seems promising. I can access the database and the web service all locally. The problem I'm having is it seems that Mongoose is locked down to only allow local connections. Is there a way to open up the Mongoose server to allow the app to be accessed from the outside world?

And while I'm at it, does anyone see any other problems I might run into?

Czarek Tomczak.

unread,
Feb 23, 2016, 12:33:50 AM2/23/16
to PHP Desktop
Hi Dallin,

There are two options:
1. Detect computer's public IP adress and set it in settings.json - web_server > listen_on - set it instead of 127.0.0.1. This could be done by installer or by phpdesktop app itself with a notification to user that he should restart app.
2. Mongoose has an option to listen on all ip addresses. A tiny patch to C++ sources would be required, see Issue 165: https://github.com/cztomczak/phpdesktop/issues/165

Czarek Tomczak.

unread,
Feb 23, 2016, 2:04:43 AM2/23/16
to PHP Desktop

Dallin

unread,
Feb 23, 2016, 12:00:55 PM2/23/16
to PHP Desktop
Tested and works! So awesome! Thanks so much!

Now just one more problem. Is there a way to make Mongoose listen on HTTPS/SSL? I can't transfer sensitive data to the web service over normal HTTP.

Czarek Tomczak.

unread,
Feb 23, 2016, 1:59:46 PM2/23/16
to PHP Desktop
Created Issue #184 with details what would need to be done: https://github.com/cztomczak/phpdesktop/issues/184

Dallin

unread,
Feb 23, 2016, 2:46:28 PM2/23/16
to PHP Desktop
Sounds a little more difficult than I feared. I did just see this older post: https://groups.google.com/forum/#!searchin/phpdesktop/set$20setting/phpdesktop/i9oHQmFRBj4/8cdDmfcv9qMJ.

Is that referring to the IE version or am I just misunderstanding what this one is talking about?

I do have one suggestion though. I think instead of appending an 's' to the port, it might be better to have two separate settings options:

listen_on
ssl_listen_on

That way you can have a different port for each and communicate with both http and https depending on the port you send to.

One more question. I wanted to allow the user to set the port to listen on via an option menu from within the program. Is there a way to set and save the settings in settings.json from within a running php desktop instance? I would you assume you would either open and write to the settings.json file somehow or save the setting to a cookie and overwrite the value coming from settings.json each time you run the program.

Czarek Tomczak.

unread,
Feb 23, 2016, 4:37:06 PM2/23/16
to PHP Desktop
On Tuesday, February 23, 2016 at 8:46:28 PM UTC+1, Dallin wrote:
Sounds a little more difficult than I feared. I did just see this older post: https://groups.google.com/forum/#!searchin/phpdesktop/set$20setting/phpdesktop/i9oHQmFRBj4/8cdDmfcv9qMJ.

Is that referring to the IE version or am I just misunderstanding what this one is talking about?

In the referred topic I thought he was asking how to connect to an HTTPS server in a PHP script. The DLL's  mentioned are included with PHP to allow for making HTTPS requests.
 

I do have one suggestion though. I think instead of appending an 's' to the port, it might be better to have two separate settings options:

listen_on
ssl_listen_on

That way you can have a different port for each and communicate with both http and https depending on the port you send to.

Modified #184:
1. Allow for "listen_on" port to be a string "443s" and "s" meaning SSL. While on it we should allow to listen on multiple specified ports. Mongoose allows listen_on to be for example "80,443s" - this listens on HTTP 80 port and HTTPS 443 port.


Please do not ask questions in Issue Tracker and don't repeat same thing in the tracker, it was already said here.
 
One more question. I wanted to allow the user to set the port to listen on via an option menu from within the program. Is there a way to set and save the settings in settings.json from within a running php desktop instance? I would you assume you would either open and write to the settings.json file somehow or save the setting to a cookie and overwrite the value coming from settings.json each time you run the program.

You can modify settings.json while phpdesktop is running with a PHP script. The file is not locked r/w. However to reflect the changes application needs to be restarted. With some Windows scripting (batch or other) app restart could be automated. Keep in mind that modifying app files may or may not be allowed depending on where binaries were installed - this is mentioned on the Knowledge Base wiki page, eg. the "RequireAdministrator.manifest" file.

Dallin

unread,
Feb 23, 2016, 5:14:38 PM2/23/16
to PHP Desktop
Please do not ask questions in Issue Tracker and don't repeat same thing in the tracker, it was already said here.

My apologies. I wasn't meaning to ask a question but to give a suggestion about the best way to solve the issue. I posted it here first but then thought it might have been better if the suggestion was with the issue, not in a random thread, so I added it there. Regardless, I like your solution better.

Thanks for all your help!
Reply all
Reply to author
Forward
0 new messages