5
votes

I have a PHP7.1 + nginx setup on Windows Linux Subsystem (WSL).
I'm mentioning WSL, so that in PhpStorm Xdebug is configured as a remote debugger, which connects via port 9000. Still WSL and PhpStorm using the same physical files.

For Symfony 4 project I'm using it's built in web-server: bin/console server:run

I've managed to set up PhpStorm to accept Xdebug connections. When the connection is established it asks or file mappings. I would expect index.php to be asked for, but the file mapping requested is: vendor/symfony/web-server-bundle/Resources/router.php.

As said in the docs inside this file - this file implements rewrite rules for PHP built-in web server. Okay.

If I accept the mapping to this file - debugging starts at router.php goes a few lines further and than nothing else happens. It doesn't jump to my public/index.php or doesn't stop on any breakpoint.

The question is - how to configure Symfony 4 debugging with Xdebug? Maybe it is something wrong with mappings or what?

3
Did you ever figure this out? - tip2tail
Not really... I quit wasting time on trying to figure that out and use dump() and var_dump() (( - bravik

3 Answers

0
votes

Through https://www.jetbrains.com/help/phpstorm/override-server-path-mappings-dialog.html, you should extend your file mappings. Probably, router.php was used as it was the first entry point to be found - but through this first file, you can see the file structure that WSL uses.

So: opening the mapping dialog should give you router.php somewhere down the structure with a mapped path which is also somewhere in a deeper directory. If you add a mapping for your root folder with the same mapping than the one used for router.php, removing vendor/symfony/web-server-bundle/Resources/router.php, you should be done

0
votes

I experienced a very similar issue, where it seems that after the initial break (First line of script), xdebug cannot continue walking through code.

PhpStorm 2017.3, Mojave 10.14, Symfony 4.2, Xdebug 2.7.1

Try upgrading PhpStorm to 2018.3 - it was the difference for me.

0
votes

You have to reinstall ssh on WSL first:

sudo apt remove openssh-server
sudo apt install openssh-server

Edit /etc/ssh/sshd_config, change PasswordAuthentication to yes and add your login user to the bottom of the file: AllowUsers yourusername

Save your changes and restart ssh:

sudo service ssh --full-restart

More info here: https://www.illuminiastudios.com/dev-diaries/ssh-on-windows-subsystem-for-linux/

At the end set remote debugging config in PhpStorm: http://blog.spameri.cz/2017/04/20/phpstorm-wsl-php.html

Remember to set proper directory mapping. For PhpStorm your files are in C:/ProjectsDir/MyProject, but for xdebug it's /mnt/c/ProjectsDir/MyProject