Nice Guy IT
Nice Guy IT

Reputation: 117

How to use live edit with router script in PhpStorm

I setup live edit in PhpStorm and it works great. While implementing routing in my application, I configured PhpStorm to use a routing script using the Built-in Web Server run configuration. At this point, live edit stopped working because it seems to work only with the built-in webserver and not the PHP built-in web server. (Technically, it didn't stop working, rather there were two run configurations: live edit where the links returned a 404 and a routing configuration that doesn't have live edit.)

I'm using PhpStorm 10.0.2 (PhpStorm-143.790) on CentOS 7.

Note: I found two issues relating to live edit and routing but neither was helpful.

  1. https://youtrack.jetbrains.com/issue/WEB-15762
  2. https://youtrack.jetbrains.com/issue/WI-20824

Thanks

Upvotes: 1

Views: 664

Answers (1)

Nice Guy IT
Nice Guy IT

Reputation: 117

A hint in the 2nd URL above provided a suitable workaround. The key lies in the fact the link between the browser and PhpStorm is not tied to the URL; only the tab. To make this work, you need two run configurations:

  1. A JavaScript Debug configuration for live edit. Make sure live edit is working.
  2. A PHP Built-in Web Server configuration with the router script enabled.

Run the JavaScript Debug configuration and it will open a tab in Chrome linked to PhpStorm. Then start the PHP Built-in Web Server configuration and change the "live edit" tab to the URL for the built-in web server. Any changes will automatically refresh the tab using the PHP Built-in Web Server configuration which contains the router functionality.

This concept can also be applied to any functionality not supported by the built-in web server, like SSL. You just need a 2nd web server (built-in or external) and change the live edit tab to the 2nd URL.

Upvotes: 0

Related Questions