Where to contribute PHP support for Windows


#1

I would like to extend the travis setup of one Project to Windows.

I have some experience installing PHP with Chocolatey, even if it is a bit rusty.
I just would like to know where I need to do the PR, and make sure its not something already worked on.


#2

I just would like to know where I need to do the PR

Probably https://github.com/travis-ci/travis-build

For PHP, you can use language: sh. For example:

os: windows
language: sh
before_install:
  - choco install php
  - export PATH=/c/tools/php72:$PATH

#3

First of all …

Thank you for your interest in bringing PHP support to Windows! We very much appreciate your enthusiasm.

I will describe how PHP support works on Linux and the Mac right now. Do keep in mind that Windows is a new game, and it would not have to happen in the same way as it does in the other two OSes. (Though, obviously, similar tooling may reduce the amount of work it would take to make it happen.)

How PHP support works now on Linux and macOS

As @mauriciofauth pointed out, much of what we would call “PHP support” on Travis CI is described in https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/script/php.rb, in particular, in this code branch:

  1. First, run phpenv global VERSION
    1. if it succeeds, use that version. This is one that is pre-installed on the build image.
    2. If it fails, grab a pre-compiled archive from our PHP archive on remote file storage (more on this in the next section).
  2. Write ~/.pearrc with reverse-engineered file content (this could be quite brittle).
  3. Run phpenv global VERSION again, and phpenv rehash to activate the new PHP run time.

Creating pre-compiled PHP archives

https://github.com/travis-ci/php-src-builder is responsible for compiling and creating new PHP archives. It sets up (if necessary) a PHP building environment, compiles PHP using php-build, and uploads the archives to the right place so that travis-build can find it at the run time.

How should PHP support on Travis look?

This is an open question. As I said earlier, I might be less work to make it look a lot like Linux and Mac. Maybe not. My understanding of the Windows ecosystem is very limited.

Option 1: Leverage current tooling

In this case, I reckon the first thing to do would be to create a base set of PHP archives for use by Windows VMs. This would start with a language: sh job on Windows, use php-build to compile, archive and upload to the remote file storage. I do not know if php-build, written in bash, is compatible with “git bash”. If it’s not, it could be some work to make it so.

This would also mean that we ensure that the Windows image has a reasonable C/C++ toolchain that we can use.

Option 2: Use Windows-native tooling

It might be more intuitive for Windows developers to use the Windows-native tools. For example, https://windows.php.net/download has many archives that might be usable. Or, alternatively, Chocolatey archive(s) might be more in tune with what we need (as suggested by @mauriciofauth).


I hope all of this makes some sense, and helps you get started.


#4

Thank you for this extensive introduction.

not sure if phpenv and php-build will properly run on windows, as they seem to be very centred on *nix systems.
There seems to be an alternative with https://github.com/tobias-trozowski/phpenv-windows

And the windows native way seems a lot easier (or chocolatey, which is basicly using the archives provided by php.net if I remember correctly)

So I guess I will work on the travis-build repository in the linked file.
I then need to get a example_payload for a php windows build and need to pipe it into the /scrip/compile and see if it runs through?
cat example_payloads/windows_php.json | bundler exec script/compile

I wonder how and what I should and could test there, and how do I validate php is working on windows?


#5

Hi All

@BanzaiMan wrote up a great summary. Also, major High 5s to @Flyingmana for there extra info.

I did a little experiment to see if I could get phpenv to work: https://staging.travis-ci.com/joshk/windows-testing/builds/234625

You can see the .travis.yml config which went with it: https://github.com/joshk/windows-testing/blob/joshk-php/.travis.yml

It failed with the error message:

configure: error: xml2-config not found. Please check your libxml2 installation.

If we can resolve this issue, we could get the install on demand option working, and then address building some archives for faster installation.

Any and all help would be greatly appreciated.


#6

I tried out a bit to install php via choco, but had problems as refreshenv was not available, so php was not added to the environment.
Also most commands are only available as their .exe version, so php will likely be also only available as php.exe inside bash. Not sure if this will be a problem.

no idea about the libxml, seems to be normally delivered with the php installer/package, and on choco I dont find a related package.
Only thing I found was https://stackoverflow.com/questions/36980095/php-configure-on-windows-enable-libxml2