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.

Give PhpStorm 7 EAP a try. And as always, let us hear your thoughts in the issue tracker, through the comments below or in our forums!

Develop with pleasure!
– JetBrains PhpStorm Team

This entry was posted in Cool Feature, Early Access Program and tagged , , , . Bookmark the permalink.
  • Michal Suski

    How do I turn it off?

    • Mikhail Vink

      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

  • Jannik

    I just tried it for fun with a symfony2 project: http://localhost:63342/Liim/web/app_dev.php (Liim is the name of the project).

    Result: 502 Bad Gateway

    • Maarten Balliauw

      Hi,

      This sounds like an issue. Can you report this at http://youtrack.jetbrains.com/issues/WI ?

      Thanks!

      Maarten

    • Shahid

      Hi Jannik, Please see my answer below against your problem. I hope, It might solve your problem.

    • andrea

      same here

  • Clint

    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.

    4- Press Apply button.

    Enjoy;-)

    • NML

      Thanks!

      • http://thx tinkl

        Thanks very much from tinkl.

  • Stophe

    Is it possible to change the port?

    • Mikhail Vink

      Yes, in Settings | IDE Settings | Debugger | JavaScript | Built-in server port.

  • John McCann

    How do I turn off the built in php server if I manage to get it stuck in an infinite loop!!!?

    The stop button doesn’t seem to work, I still get masses of output scrolling past.

  • 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 :-(

  • howdy
  • rearndt

    Let’s try asking Mr. Suski’s original question again :

    How do you turn this built-in server OFF?

    The operative word here is “OFF”. I did not purchase a license for this product to be dictated to about how to serve my pages.

    I hope this is not too difficult.

    Thanks.

    • Maarten Balliauw

      See http://youtrack.jetbrains.com/issue/WEB-9144 – it is not possible at the moment but you do not have to sue it. Working with your own prefered server is fine too.

      • Robert Arndt

        Thanks, Maarten. This was absolutely ZERO help. I really appreciate it.

        • Maarten Balliauw

          Hi Robert,

          You can still work with PHP’s built-in server, Apache, IIS or any other webserver. You do not have to use the built-in server, you are free to use whichever webserver you prefer.

          As for turning it off, that indeed is not possible at the moment. It is locked down to only accept connections from localhost by default, and not from the internal network.

          If you do feel turning it off completely, please continue the discussion at http://youtrack.jetbrains.com/issue/WEB-9144.

          Best regards,
          Maarten

  • Bob Spero

    I tested this also and get 502 error as well on ubuntu 13.10

  • http://dc-development.de Phil

    just got it working.

    Bad Gateways, and how do I use my own server.

    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).

    eg. if we had within a html file . Instead of referencing http://localhost:63342/project/img/1.png it instead references http://localhost:63342/img/1.png

    Would it be possible to set the project at the localhost domain?

    • Maarten Balliauw

      You can always log it in our issue tracker at http://youtrack.jetbrains.com/issues/WI as it may make sense.

      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/