[SOLVED] Running & Debugging PHP through Linux Bash Subsystem on Windows 10

I am developin on Windows 10 machine, and wanted to use Linux PHP binary in Bash on Ubuntu on Windows (WSL subsystem) directly for running scripts and debugging from inside PhpStorm.

I created a proxy scripts that let PhpStorm think that PHP binary is installed on the system. But in the background, they start the PHP inside the Windows Bash and forward everything to it. Also XDebug is working.

Maybe you could enjoy this little helper as well :-) And if you had time to write me a feedback, I would be more than happy.

> Download: https://github.com/michal-kocarek/PhpOnWindows

1 comment

Why is this needed - am I missing something subtle....?

If under WSL you set the following in your php.ini:


[xdebug]

zend_extension="<path to your xdebug.so"

xdebug.remote_enable=on

xdebug.remote__connect_back=on

Then add the XDEBUG_SESSION_START query param to your http request for the file you wish to debug, as long as you have opened port 9000 for incoming traffic in the Windows Firewall everything works just fine. Just configure PhpStorm to use a remote server with local source files, make sure you have listening turned on, and you're good to go. This way you can use postman to make your requests for API debug too. 

You can use COOKIES instead of the XDEBUG_SESSION_START query param if preferred and there are browser extension to help with that.

Nick Weavers

 

0

Please sign in to leave a comment.