Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPStorm: Open in Browser option: How to set default server to open?

For PHPStorm, I have opened a project/site at location C:\site. Then, I went ahead and added a built in PHP Webserver at localhost port 8081 from the Menu Bar: Run > Edit Configurations.

To view index.php file, when I click on View > Open in Browser > Chrome (or any other browser), it takes me to http://localhost:63342/site/index.php

So, looks like it created another server running at port 63342? Also, it has the path as /site/index.php instead of just /index.php.

Is there a way to configure so that when I click view > open in browser > browser_name, it will take to localhost:8081/index.php?

Also, is it possible to turn off that server running at 63342 port?

Version: I am trying on PHPStorm 8 and 9 and both show same behavior.

like image 518
user3330840 Avatar asked Aug 02 '15 00:08

user3330840


1 Answers

http://localhost:63342/PROJECT_NAME/ is PhpStorm's own simple built-in web server in action. It is used if no Deployment entries are defined (or defined but non of them is marked as default for this project).

When you use Open in Browser action IDE checks your deployment settings looking for base URL that will be used to open such file in a browser. If it finds no such entries then instead of opening this file using file:// protocol it uses its' own built-in web server.

So .. to use your specific web server / URL you have to:

  1. Settings (Preferences on Mac) | Build, Execution, Deployment | Deployment
  2. Create new entry of appropriate type (or finish configuring already existing one, if you have done it already)
  3. Configure it (provide URL and paths) so that no warnings is shown for first 2 tabs (Connection & Mappings).
  4. Mark such entry as Default for this project

Now IDE will use those details when you use Open in Browser action.

NOTE: that Open in Browser action will not launch your web server (the one you have created for port 8081) -- it just opens URL in browser. You will have to make sure that your server is already running before using this action.


Useful links:

  1. Deployments in PhpStorm
  2. Using the Built-in Webserver in PhpStorm
like image 135
LazyOne Avatar answered Oct 21 '22 04:10

LazyOne