How to start Symfony web server from PhpStorm
- Click
Run -> Edit Configurations
- In the dialog box Click
+
(add) - Select
PHP
from the dropdown list - In the field name field
Symfony Web-Server
- In the Script field, enter the path to
bin/console
for example:/path/to/symfony/bin/console
- Optionally uncheck the box
Activate Tool Window
to prevent it from appearing on startup - In the arguments box, enter
server:run
- Click "OK" to save and close the dialog
This will give you the option to choose Run Symfony Web-Server
and Debug Symfony Web-Server
. To debug a running server, you must tell PHPStorm to listen for debug connections before starting the server script. To set up debugging in Settings -> Languages & Frameworks -> PHP -> Servers
, make sure you build 127.0.0.1:8000
, disable Path Mapping
, and you install Xdebug as the debugger. Optionally disable the stop in the first line in the settings Debug -> XDebug
.
You can now start the server by selecting it from the Run drop-down list and clicking the Play button. Make sure to tell PHPStorm to listen for debug connections first.
or by clicking Run -> Symfony Web-Server
.
Add breakpoints, then launch your browser on the Route affected by the breakpoints, and PHPStorm should hijack the debug session and break as desired.
If debugging fails at first, close all running PHPStorm services and try starting Debug Symfony Web-Server
(make sure PHPStorm is listening for debug connections), then restart your browser. For some reason, Xdebug may not initialize otherwise, but this behavior is sporadic and difficult to reproduce consistently. Once initialized, you can start a non-debuggable web server when listening is enabled and it seems to work fine.
Note that
Debug Symfony Web-Server
only the bin / console script will control the launch . This is because the symfony server php process is forked and the debug session will be left keeping track of the parent process. So you have to say that PHPStorm is listening for debug connections when debugging the web server.
source to share