简体   繁体   English

PHPStorm:在浏览器中打开选项:如何设置默认服务器打开?

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

For PHPStorm, I have opened a project/site at location C:\\site. 对于PHPStorm,我已经在位置C:\\ site处打开了一个项目/站点。 Then, I went ahead and added a built in PHP Webserver at localhost port 8081 from the Menu Bar: Run > Edit Configurations. 然后,我从菜单栏中在本地主机端口8081处添加了一个内置的PHP Webserver:运行>编辑配置。

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 要查看index.php文件,当我单击视图>在浏览器中打开> Chrome(或任何其他浏览器)时,它将带我到http:// localhost:63342 / site / index.php

So, looks like it created another server running at port 63342? 如此看来,它创建了另一个在端口63342运行的服务器? Also, it has the path as /site/index.php instead of just /index.php. 另外,它的路径为/site/index.php而不是/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? 有没有一种配置方法,当我单击视图>在浏览器中打开> browser_name时,它将带到localhost:8081 / index.php?

Also, is it possible to turn off that server running at 63342 port? 另外,是否可以关闭在63342端口运行的服务器?

Version: I am trying on PHPStorm 8 and 9 and both show same behavior. 版本:我正在PHPStorm 8和9上尝试,并且都显示相同的行为。

http://localhost:63342/PROJECT_NAME/ is PhpStorm's own simple built-in web server in action. http://localhost:63342/PROJECT_NAME/PhpStorm自己的简单内置网络服务器 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. 使用“ Open in Browser操作时,IDE会检查您的部署设置,以查找将用于在浏览器中打开此类文件的基本URL。 If it finds no such entries then instead of opening this file using file:// protocol it uses its' own built-in web server. 如果找不到任何此类条目,则使用其自己的内置Web服务器而不是使用file://协议打开此文件。

So .. to use your specific web server / URL you have to: 所以..要使用您的特定Web服务器/ URL,您必须:

  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). 配置它(提供URL和路径),以使前两个选项卡(“连接和映射”)不显示警告。
  4. Mark such entry as Default for this project 将此项目标记为默认

Now IDE will use those details when you use Open in Browser action. 现在,当您使用“ Open in Browser操作时,IDE将使用这些详细信息。

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. 注意:“ Open in BrowserOpen in Browser操作不会启动您的Web服务器(您为端口8081创建的服务器),而只是在浏览器中打开URL。 You will have to make sure that your server is already running before using this action. 使用此操作之前,您必须确保服务器已在运行。


Useful links: 有用的链接:

  1. Deployments in PhpStorm PhpStorm中的部署
  2. Using the Built-in Webserver in PhpStorm 在PhpStorm中使用内置的Web服务器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM