Being a GWT newbie, I want to create GWT frontend and a PHP backend, communicating via JSON.
The GWT Getting started docs (http://code.google.com/intl/sv-SE/webtoolkit/doc/latest/tutorial/JSONphp.html) suggests
compiling the GWT frontend, and
moving it to an Apache/IIS server
Is there a way to avoid this roundtrip?
Could Jetty and a localhost Apache be set up to run simultaneously so that GWT frontend development (hosted mode) could be done in parallell with PHP backend dev?
Alternatively, could GWT Host mode be setup to use localhost Apache/Tomcat instead of Jetty?
Yes it's possible. You have to do the following:
compile once the gwt project and copy it to the php server (you can compile directly to the php server -war option
run dev mode with the -noserver option (this way you won't use the embedded jetty server)
make sure your php project loads the appropriate gwt host file
you should have the apache/IIS server running while in dev mode.
set the appropriate url in the gwt run configuration (if you use eclipse) to load the page with the hosted file on your apache server
Browsers pages (javascript) are normally only allowed to communicate to their origin servers. There are ways around it, but require changing your html pages, which makes no sense since you only need this for developments.
A better solution would be to just copy necessary files to your PHP project directory after every GWT compile. Ant can do this and your IDE maybe too.
Related
I'm new to React. I have a button in one of the components, on clicking the button, a server side (PHP) call should be made using axios GET call and the response should change the state of the store.
I have set the app using webpack and using the express server.
What changes to their settings be made in order to run PHP code?
I have set the app using webpack and using the express server. What changes to their settings be made in order to run PHP code?
You don't have to change any settings there. These tools can't run PHP code. If you want to serve your static files (.html, .css, .js) with express you can leave that as it is. But you have to run another local webserver next to express that can run PHP code and that listens on another port. PHP 5.4+ has a built-in development server. Or you can use nginx or apache.
You could use e.g. Laravel which is a popular web application framework. This makes it easy to run a local development server and to define a RESTful api which you will need to provide in order to communicate with your react app. Laravel uses the built-in PHP web server. When you installed Laravel you can start it with:
php artisan serve
This command will start a development server at http://localhost:8000. Express is per default running at http://localhost:3000.
Then you can define a REST api in Laravel and send requests to it.
Of course you can use other PHP frameworks too if you don't want to use Laravel.
I am developing APIs in node js and have hosted the application on amazon EC2. In a third party API it is required to host a php page on our server and give its public url back to them. Is there another way to host it apart from a LAMP setup? Anything apart from EC2 is also fine but please take into consideration that this is a single page having some logic and nothing else will be there in PHP.
I work with node and php. I would recommend NGINX. It's configuration files are really simple and it's much lighter-weight than apache.
You can simply create a redirect/rewrite directive in NGINX that will pass your php page to the node server instead and be done. For this usecase, you wouldn't actually even need to install or configure the PHP backend.
http://nginx.org/en/docs/beginners_guide.html#proxy
You might also check AWS domain management tools (AWS Route 53). There may be a way to directly rewrite the incoming PHP request to go to your node app instead without installing any webserver on your EC2.
Yes, there are other web-servers available apart from apache: For instance Nginx plus or Lighttpd, both are fine and lightweight alternatives to host your PHP files on EC2.
Though, it's not clear to me why don't you like the LAMP setup. Maybe Apache+PHP, without MySQL, would be enough for you?
I'm developing a SPA that runs on Backbone.js locally and setting server up with Grunt for livereload . I did a REST api with PHP for my app which i also run locally. Now i have a problem with cross domain policy since my servers are on different ports. I tried to combine two servers on one port both from apache and from grunt but i'm not sure if it is at all possible. How should i deal with this problem? i would like to develop my app locally and use the livereload features of grunt.
I propose installing nginx to act as reverse proxy. It can serve static files from one directory (aka frontend), and server side generated scripts (aka backend) from other server.
It serves backend, if the request do not corresponds to the file existing in frontend directory.
This is config example for it - https://github.com/vodolaz095/hunt/blob/master/examples/serverConfigsExamples/nginx.conf
It serves static html, css, js files from directory /home/nap/static and backend from the localhost:3000, and both of them are accessible on localhost:80 as the one server.
I hope this is what you need.
So i ended up using grunt-connect-proxy which did just what i needed.
It seems like there are two ways to go, and the determining factor is whether you want to host on your own computer, or through a webhost.
If I have an IDE, a webhost server I subscribe to, and an FTP client to transfer my files to the server, then I don't need to install PHP, MySQL, and XAMP, right?
I know XAMP allows me make my computer website server.
When I install PHP, am I installing the intepreter for my computer/server to parse the .php files? (and same for MySQL?)
If I pay for web hosting, then their servers already have PHP and MySQL parsers, and all I need to do is upload my text files, right?
Thanks in advance
U just cant simply put the files in server without developing them.and if you want to develop any website or any webapp then u need to make your system a local server where you can execute your server side languages like php.XAMP is a short form for mysql,apache and php for windows.and 'website server' is not the proper word.use LOCALHOST instead because only u will have access to your server unless you are connected via LAN or WAN.so i can summarize the above in few points keeping in mind that you want to develop your website.
step 1:install XAMP
step 2:develop and test your scripts.
Step 3:if everything works fine than host your site in the webserver for everybody to see it.
I have a web application that uses both localstorage but also server side SQL storage. When I test my APK file using Eclipse only the html pages with localstorage work and not the server stuff in the PHP files. How can I direct my PHP files to go to a server since all the APK does it package everything on the client side?
Thanks
You can run PHP on Android. Try SL4A. Web servers can exist on a mobile. There are quite a few that function as a local server, within Android apps.
You can't run php files on mobile except on the browser
So if you want to run PHP files put them on the server and invoke them to return or accept data from you
To run PHP files you need a web server which doesn't exist on a mobile
I believe that you asked this because you could run javascript & HTML files on the mobile
I will recommend two things
1- If you need to run PHP make ana AJAX request on it and keep it on the server and remember the cross-domain
2- you need to consider the performance of the app you are making because after personal experience its slow
One More thing it works on the chrome because you have a web server (APACHE) on your machine