phpgwtjettygwt-dev-mode

Configure GWT Dev Mode Jetty Server for executing php scripts


I've been trying several examples that I've found online to have a PHP script called by an web application developed with GWT (via Eclipse) using HTTP requests. I figure once I get this to work I can apply the techniques to my own application. However, I am having a horrible time trying to get this to work. The closest that I've come to success is with the StockWatcher application found at https://developers.google.com/web-toolkit/doc/2.1/tutorial/gettingstarted (I also worked the example starting at the JSON-PHP implementation here https://developers.google.com/web-toolkit/doc/2.1/tutorial/JSONphp)

The StockWatcher example has you place a PHP script in the "war" directory. When I start with the basic example, with the following snippet defining the url string (Notes: The value for q is added after the code snippet below XXX = localhost, and YYY = 127.0.0.1:8888)

private static final String JSON_URL = GWT.getModuleBaseURL() + "stockPrices?q=";
String url = JSON_URL;

which gives the url as

"http://_YYY_/stockwatcher/stockPrices?q=";

I get at 404 error code, even if I move the PHP script to the .../war/stockwatcher directory.

If I hardcode the url:

url = YYY/stockPrices.php?q=">http://YYY/stockPrices.php?q=;

the PHP script is found but the script file is just echoed back the the client routine. This subsequently results in an exception because the client routine is expecting JSON.

Now if I change the url to

url = http://_XXX_/StockWatcher/stockPrices.php?q=;

refresh the project, copy the contents of the "war" directory to C:\wamp\www\StockWatcher, and enter XXX/stockwatcher/stockwatcher.html">http://XXX/stockwatcher/stockwatcher.html in my browser (I'm using Chrome), then everything works like a charm (I have Wampserver running on my PC).

While I might be using the Wampserver in the production system, I'd still like to debug within Eclipse. Does the built in server, Jetty, that comes with Eclipse and the GWT plugin not work with PHP?

Thanks so much in advance, Bill


Solution

  • If you're not going to deploy your app in a servlet container, then there's absolutely no reason you'd want to try running a PHP script within DevMode's servlet container.

    The thing to do is:

    1. point your WAMP server at your war folder, or alternatively point the DevMode and Compiler -war at some folder served by your WAMP server
    2. start DevMode without the embedded Jetty: pass -noserver and use the http:// URL to your WAMP server as the -startupUrl (from Eclipse, use Run As → Web Application (running on external server))

    See https://developers.google.com/web-toolkit/doc/latest/DevGuideCompilingAndDebugging#How_do_I_use_my_own_server_in_development_mode_instead_of_GWT%27s