This is bridge from Windows to PHP installed under Windows Linux subsystem (Bash on Ubuntu on Windows) providing native integration for JetBrains IDEs, full XDebug support and simplicity for running PHP scripts.
NOTE: This project is proof of concept. Use in development environments only! Expect bugs when stepping outside of the happy path.
- Windows PHP distribution
- Bash on Ubuntu on Windows
- PHP distribution inside that Ubuntu
-
Clone this repository somewhere (e.g.
C:\PhpOnWindows
). -
Create file
.php-path
inside that directory. Write absolute path to yourphp.exe
to that file. (e.g.echo C:\PHP\php.exe > C:\PhpOnWindows\.php-path
)
- Use
php.cmd
script just as if it was your regular PHP executable.
Working directory is preserved. File paths in command arguments are mapped into /mnt/<drive>/
folder automatically.
-
Create new PHP configuration and set your
php.cmd
as PHP executable. -
That's it!
You should see that IDE reads configuration properly. XDebug, when installed, should work right now.
User starts php.cmd
batch.
Batch file starts Windows PHP process by running php-bridge.php
script and passes to it all command line arguments.
Script starts bash.exe
with arguments to run the PHP script inside the Linux. But before composing the command line
passed to the Bash, following must be done:
-
Windows-like file path is mapped to Linux-like (basically
C:\...
gets mapped to/mnt/c/
). -
If XDebug settings are found inside command line arguments, XDebug "proxy" is started. As IDE and XDebug instance exchange file paths between each other, script takes care of file paths mapping as well.
Standard output and error output are preserved. Exit code returned by the script is preserved as well.
Open php.cmd
file and set PHP_IN_BASH_LOGGING
variable to 1
. Then watch the script output during next run.
In case of problems just drop me a message, file an issue or create a pull request.
Michal Kočárek [email protected] – https://twitter.com/michalkocarek
This library is licensed under the MIT License – see the LICENSE file for details.