Deployment - switching between local and remote servers

Hi everyone,

I'm new to IDEA, so this might be a basic question. I'm working on a website, which includes PHP files. I've configured WAMP as my local server, and when I click on one of the 'open in browser' icons, a preview of the page opens at http://localhost:63342/mywebsite/about.php?_ijt=oju0rdq7rf6qseqvth6lnjd8su - and everything looks great.

I then investigated how to ftp and set up the hosting/remote server details. This all works fine, ftp connects and I can upload files to my hosting service. However, because I had to enter 'Web server root URL:' in the Settings>Deployment>Connection tab, when I click on one of the browser icons, I'm no longer taken to the localhost version but the actual published site at www.mywebsite.com/about.php.

Is there an easy way to preview a page at the local address during development? Should I perhaps set up two servers, one local, one remote and switch between the two?

 

Many thanks.

0

Hi there,

>Should I perhaps set up two servers, one local, one remote and switch between the two?

Yes -- that would be the best overall approach if you want to keep using "Open in Browser".

SIDE NOTE: the "http://localhost:63342/mywebsite/about.php" URL is not your WAMP but PhpStorm's simple built-in web server (where "mywebsite" is the project name). It is used by default when no default deployment entry is configured. Depends on your code and use case it may not be that good as proper Apache from your WAMP would be (mainly because of "/project_name/ part must be present in URL" requirement).

Possible alternative: create dedicated Run/Debug Configuration of most appropriate type -- it will allow to execute it ignoring the currently selected deployment entry.

1

Thanks for the reply Andriy, really appreciate your help.

I think your suggestion of creating a Run/Debug Configuration sounds good so that when I hit the run/dubug buttons a local server preview opens up (either with WAMP or PhpStorm, I don't mind which), then when I want to deploy I can just right-click the file > Deployment > upload to mywebsite.

Any advice on how I can setup the Run/Debud Configuration to open up a local preview? I tried going into 'edit configurations' > default > PHP Web Application but I'm not sure of what details to enter on the configuration screen. I tried creating a host at http://localhost/ : port 80 with start URL localhost/mywebsite/ but hitting the run or debug button just runs through the code in the console window.

Thanks again.

 

 

 

 

0

1) Not "default "branch. I think "default" should be clear enough .. that it's not an actual entry but a template that will be used for all future entries of that particular type. Use "+" button to create an entry of required type (e.g. "Web application")

2) Use URL that works for you (be it your Apache from WAMP or built-in web server). The URL for built-in web server you should know (as it was you who mentioned it on first place). https://confluence.jetbrains.com/display/PhpStorm/Using+the+Built-in+Webserver+in+PhpStorm

>but hitting the run or debug button just runs through the code in the console window.

This means that you have created an entry of the wrong type. Quite likely "PHP Script" type that is meant for running scripts in CLI environment.

1

请先登录再写评论。