PHP in hosted mode

14 views
Skip to first unread message

Basilevs

unread,
Jan 16, 2008, 10:14:16 AM1/16/08
to Google Web Toolkit
Hello.

Is there a way to use PHP as server side language in hosted mode?
How do I integrate PHP interpreter in hosted mode web-server?

Thank you.

Jean-Philippe Côté

unread,
Jan 16, 2008, 4:35:12 PM1/16/08
to Google-We...@googlegroups.com
Hi,

I tried this earlier this week, here my shell file:

@java -cp "%~dp0\src;%~dp0\bin;D:/dev/gwt-windows-1.4.60/gwt-user.jar;D:/dev/gwt-windows-1.4.60/gwt-dev-windows.jar" com.google.gwt.dev.GWTShell -noserver -whitelist " ^http[:][/][/]192[.]168[.]0[.]161" -out "Z:/sandbox/hostedmode" %* http://192.168.0.161/sandbox/hostedmode/com.Test.TestProject

Z:/ is my web server home folder.

http://192.168.0.161/sandbox/hostedmode/com.Test.TestProject is the absolute path to my webapp.

Here is the help file that I used : http://code.google.com/support/bin/answer.py?answer=55200&topic=13017

Now I need to figure how to put breakpoint and how to step in my code... Perhaps next week :)

Hope this help.

Ian Bambury

unread,
Jan 16, 2008, 6:30:39 PM1/16/08
to Google-We...@googlegroups.com
I use a different method.
 
I keep the dev php code in the project e.g. in the current project this is /RXChat-1.1.001/src/com/roughian/chat.public/php/ which means it is easy to edit in Eclipse, just like any other file in the project.
 
In the project directory I put a copy of Abyss (web server - 500Kb) and a copy of PHP (16Mb) - so every project using PHP has these. The advantage of having both these in the project directory is that a) you can use relative paths which makes it portable and b) once set up, if you change to work on a different project, you shut down one Abyss server and fire up the preconfigured one in the project folder.
 
So anyway, you point Abyss's webroot at your public directory so it picks up your development files and add in PHP and off you go.
 
The only other thing is that calls in code to php programs go by default to Tomcat on localhost:8888 and you need to get your PHP files from plain old localhost (Abyss on port 80) . So you need a routine to switch depending what you are doing

    private final static String getPhpUrl()
    {
        String url = GWT.getModuleBaseURL();

        String bits[] = url.split("/");
        if (bits[2].equals("localhost:8888")) url = "
http://localhost";
        return url + "/";
    }

You can also change the port Abyss is running on for each project and then you can run 4 or 5 copies of Abyss and swap between projects at will. Personally I don't bother.
 
Nowhere near as concise as Jean-Phillipe's answer, but this way all the code runs out of the project directory and is therefore available directly in Eclipse, and you can run hosted mode straight out of Eclipse complete with JUnit and debug
 
If you need more info, let me know.
 
 
 
 
On 16/01/2008, Jean-Philippe Côté <jean.phili...@gmail.com> wrote:
Hi,

I tried this earlier this week, here my shell file:

@java -cp "%~dp0\src;%~dp0\bin;D:/dev/gwt- windows-1.4.60/gwt-user.jar;D:/dev/gwt-windows-1.4.60/gwt-dev-windows.jar" com.google.gwt.dev.GWTShell -noserver -whitelist " ^http[:][/][/]192[.]168[.]0[.]161" -out "Z:/sandbox/hostedmode" %* http://192.168.0.161/sandbox/hostedmode/com.Test.TestProject

MikeL...@gmail.com

unread,
Feb 12, 2008, 7:32:13 PM2/12/08
to Google Web Toolkit
Ian,

How does using http://localhost as the URL base for XMLHttpRequest get
us past the same-origin policy where hosted mode is running from
localhost:8888?

There was a similar discussion about using Eclipse's http proxy to go
directly from localhost to the target PHP server, but they seam to
have run into the same problem. localhost != localhost:8888. Only
solution seams to be either serve RPC from embedded Tomcat (only Java
RPC) or export the compiled output from GWT and run hosted mode by
serving all dynamic and static content from the server (almost
deployed but still allows java debugging).

Is there something I am missing?
> On 16/01/2008, Jean-Philippe Côté <jean.philippe.cot...@gmail.com> wrote:
>
> > Hi,
>
> > I tried this earlier this week, here my shell file:
>
> > @java -cp "%~dp0\src;%~dp0\bin;D:/dev/gwt-windows-1.4.60/gwt-user.jar
> > ;D:/dev/gwt-windows-1.4.60/gwt-dev-windows.jar"
> > com.google.gwt.dev.GWTShell -noserver -whitelist "
> > ^http[:][/][/]192[.]168[.]0[.]161" -out "Z:/sandbox/hostedmode" %*http://192.168.0.161/sandbox/hostedmode/com.Test.TestProject
>
> > Z:/ is my web server home folder.
>
> >http://192.168.0.161/sandbox/hostedmode/com.Test.TestProjectis the
> > absolute path to my webapp.
>
> > Here is the help file that I used :
> >http://code.google.com/support/bin/answer.py?answer=55200&topic=13017
>
> > Now I need to figure how to put breakpoint and how to step in my code...
> > Perhaps next week :)
>
> > Hope this help.
>

MikeL...@gmail.com

unread,
Feb 12, 2008, 8:04:27 PM2/12/08
to Google Web Toolkit
Ian,

Sorry, I needed to disable my internal checks for hosted mode (to fail
XHR).

This does work. Tomcat's same-origin must be same-host only, which
works find with the Eclipse proxy. Thanks for your posts which helped
me get to a functional hosted mode test environment.

On Feb 12, 7:32 pm, "MikeLisa...@gmail.com" <MikeLisa...@gmail.com>
wrote:
> Ian,
>
> How does usinghttp://localhostas the URL base for XMLHttpRequest get
> us past the same-origin policy wherehostedmodeis running from
> localhost:8888?
>
> There was a similar discussion about using Eclipse's http proxy to go
> directly from localhost to the targetPHPserver, but they seam to
> have run into the same problem. localhost != localhost:8888. Only
> solution seams to be either serve RPC from embedded Tomcat (only Java
> RPC) or export the compiled output from GWT and runhostedmodeby
> serving all dynamic and static content from the server (almost
> deployed but still allows java debugging).
>
> Is there something I am missing?
>
> On Jan 16, 6:30 pm, "Ian Bambury" <ianbamb...@gmail.com> wrote:
>
> > I use a different method.
>
> > I keep the devphpcode in the project e.g. in the current project this is /
> > RXChat-1.1.001/src/com/roughian/chat.public/php/ which means it is easy to
> > edit in Eclipse, just like any other file in the project.
>
> > In the project directory I put a copy of Abyss (web server - 500Kb) and a
> > copy ofPHP(16Mb) - so every project usingPHPhas these. The advantage of
> > having both these in the project directory is that a) you can use relative
> > paths which makes it portable and b) once set up, if you change to work on a
> > different project, you shut down one Abyss server and fire up the
> > preconfigured one in the project folder.
>
> > So anyway, you point Abyss's webroot at your public directory so it picks up
> > your development files and add inPHPand off you go.
>
> > The only other thing is that calls in code tophpprograms go by default to
> > Tomcat on localhost:8888 and you need to get yourPHPfiles from plain old
> > localhost (Abyss on port 80) . So you need a routine to switch depending
> > what you are doing
>
> > private final static String getPhpUrl()
> > {
> > String url = GWT.getModuleBaseURL();
>
> > String bits[] = url.split("/");
> > if (bits[2].equals("localhost:8888")) url = "http://localhost";
> > return url + "/";
> > }
> > You can also change the port Abyss is running on for each project and then
> > you can run 4 or 5 copies of Abyss and swap between projects at will.
> > Personally I don't bother.
>
> > Nowhere near as concise as Jean-Phillipe's answer, but this way all the code
> > runs out of the project directory and is therefore available directly in
> > Eclipse, and you can runhostedmodestraight out of Eclipse complete with
Reply all
Reply to author
Forward
0 new messages