Built-in Webserver in PhpStorm

Ever since PhpStorm 6, we’ve had a built-in webserver which could serve up static content like HTML, JavaScript and CSS. With the latest version of the PhpStorm 7 EAP we have now added support for serving PHP from this webserver as well!

How does this work? It’s pretty easy! After opening a project in PhpStorm, navigate to http://localhost:63342/<projectname>. For example when working in a project called HelloWorld, navigate to http://localhost:63342/HelloWorld/. This URL will serve our project files using the project root as the webserver’s content root.

We have a short tutorial available with some more details on this feature.

Now it can’t be turned off, but in case you worry about security – it doesn’t accept external connections by default. There is an issue on providing enable/disable checkbox – feel free to watch it http://youtrack.jetbrains.com/issue/WEB-9144

What, then, is the use of also creating a run configuration utilizing PHP 5.4+’s built in web-server if this is now available? Is it not redundant to setup a run configuration with PHP’s built in webserver if the fast-cgi version of PHP is running anyways and can’t be disabled? What are the pros/cons of each method? The documentation doesn’t cover the differences.

Maarten Balliauw

Setting up a run configuration allows you to specify additional options your application may need. The built-in server uses the current PHP.ini but does not allow specifying additional runtime options. It also hosts your app under a directory and not at the root as opposed to the PHP-provided server.

Clint

What is the purpose of keeping the Fast-CGI executable running at all times without the ability to stop it?

The run configuration PHP built-in webserver method allows us to easily stop the server between runs. So, why do we have an ability in one instance that we don’t have in the other? It seems a lot of people want it.

Shahid

Hi Jannik, i have figured out why are you having that problem. Well, all you need to do is to figure out your php interpreter. This could be done by following these simple steps:
1- Open phpStorm.
2- Go to File -> Settings -> php

There you will have dialog, where on the very top of it, you can see the php language level (installed on your system will automatically be configured by phpStorm).

3- In the next Interpreter combo list, you will look for the directory where your php folder resides like in my case it was: C:\xampp\php

What it does is that it fetches the php.exe file from it which works as an interpreter for all the php code you write in your IDE.

The easier way is to change Interpreter to another one, click Apply and then change it back. This will force built-in server to restart.

Sam

I get the error:

php-cgi not found
Please ensure that configured PHP Interpreter built as CGI program (–enable-fastcgi was specified)

Is there some easy way to do this? (I’m on Ubuntu)

Mikhail Vink

phpinfo(); function, there is “Configure Command” to check that.

howdy

I have also run into this same issue —

php-cgi not found
Please ensure that configured PHP Interpreter built as CGI program (–enable-fastcgi was specified)

I do not have any enable fastcgi entries in my php.ini. What is the “Configure Command” you’re referring to?

howdy

I’m also running on Ubuntu 12.04 and compared the phpinfo() listed on the page and my own. I don’t have a Configure Command field as listed above. Also, my “Server API” is “Apache 2.0 Handler” and not “CGI/Fast CGI” as listed in the Windows phpinfo() file at the top of the page.

tornodo

just do this :sudo apt-get install php-cgi

Timid

Noob here.

I am on a Mac; where can I find the files to install and how do I do that Please.
I tried installing with brew and located a fcgi package. But that doesn’t seem te work

1. Make sure php5-cgi is installed (sudo apt-get install)
2. Meditate over this sentence: “LiveEdit Since version 0.5 LiveEdit works as part of JavaScript debug session”.

I overread this several times. Then I remembered to ponder twice, whatever is printed fat.

3. After having setup a Javascript “Debug-Session in JB it worked. 😉

4. If you’re using your own server just make sure you configure the path in the script-debug session (theres a field for “path” you type the URL you want to debug)

5. Last but not least – the JB-Chrome plugin will state that it is: “connected to JetBrains IDE” if it finds a running instance on your computer but as long as you didn’t install the LiveEdit Plugin in your IDE, this wont be of much help.

Have Fun

Phil

Ryan Sheehy

Hi,

When using this built-in server to test html, js, or css code with domain root reference it doesn’t link properly to the asset (no doubt happening due to the project’s folder being placed one directory level up on the localhost domain).

On a side note, I feel that depending on the URL structure may not be the most optimal choice. What if teh application is to be deployed in a subdirectory of the virtual host later on? Ideally, a helper class could create the correct URL to be used, based on the URL where the application is deployed. Found a good post on this here: http://michaelkimsal.com/blog/is-your-code-portable-to-subfolders/