Allow building PHP plugin with mingw and cmake. Cleanup duplicate code.
Merge pull request #543 from Alexpux/master

Allow building PHP plugin with mingw and cmake. Cleanup duplicate code.