Coder Social home page Coder Social logo

phponwindows's Introduction

PhpOnWindows

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.

PhpStorm with debugging session running through PHP on Ubuntu on Windows

Prerequisites

Installation

  1. Clone this repository somewhere (e.g. C:\PhpOnWindows).

  2. Create file .php-path inside that directory. Write absolute path to your php.exe to that file. (e.g. echo C:\PHP\php.exe > C:\PhpOnWindows\.php-path)

Usage

  1. 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.

Linux PHP executable running in Windows command line

Usage in JetBrains IDE

  1. Create new PHP configuration and set your php.cmd as PHP executable.

  2. That's it!

You should see that IDE reads configuration properly. XDebug, when installed, should work right now.

PhpStorm settings with path to php.cmd set

How it works?

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.

Troubleshooting

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.

Contact

Michal Kočárek [email protected]https://twitter.com/michalkocarek

License

This library is licensed under the MIT License – see the LICENSE file for details.

phponwindows's People

Contributors

vassyli avatar

Watchers

Darryl Porter avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.