Pickle expects to find a simple string containing the version number in the headers, however this extension is building the version string dynamically, so Pickle ends up with a version of 'PHP_SQLSRV_VERSION' which leads the following error:
In Loader.php line 141:
Version mismatch - 'PHP_SQLSRV_VERSION' != '5.8.1' in source vs. XML
Would it be possible to define these constants as simple strings instead?
https://github.com/microsoft/msphpsql/blob/d92cc3d58d84f4bf6af22fe45de10170591e538b/source/shared/version.h#L64-L65
Thanks for bringing this to our attention @duncan3dc
We will get back to you on this
hi @duncan3dc thanks for your patience. I just tested it in Linux Ubuntu 18.04 and could reproduce this based on pickle readme.
Note that 5.9.0preview1 is the latest PECL package, and this is what I see:
$ php pickle.phar info sqlsrv
- Installing sqlsrv (latest-stable): Downloading (100%)
In VersionParser.php line 176:
Invalid version string "5.9.0preview1"
info [--tmp-dir TMP-DIR] [--] [<path>]
$ php pickle.phar info sqlsrv-5.8.1
- Installing sqlsrv (5.8.1): Downloading (100%)
In Loader.php line 141:
Version mismatch - 'VER_APIVERSION_STR SEMVER_PRERELEASE' != '5.8.1' in sou
rce vs. XML
info [--tmp-dir TMP-DIR] [--] [<path>]
In trying to understand what changes are required, I found this manual. Does it mean preview is no longer accepted, only beta, RC, etc.?
Is there any other documentation to ease migration and/or support Pickle?
There's two problems there, one is that yes the latest tag using the prefix "preview" isn't valid, the valid modifiers are:
alpha (or just a)beta (or just brc (release candidate)But even if that was fixed, the second problem (the one this PR was raised for) is still an issue, these lines here:
https://github.com/microsoft/msphpsql/blob/d92cc3d58d84f4bf6af22fe45de10170591e538b/source/shared/version.h#L64-L65
Should be:
#define PHP_SQLSRV_VERSION "5.9.0"
#define PHP_PDO_SQLSRV_VERSION "5.9.0"
or in the case of preview releases:
#define PHP_SQLSRV_VERSION "5.9.0-beta1"
#define PHP_PDO_SQLSRV_VERSION "5.9.0-beta1"
Thanks @duncan3dc. From my brief testing, changing the two versions from macros to plain strings work for a stable version (tested with the latest 5.8.1). However, installing the latest preview still failed in VersionParser.php line 176 because of some issues with the package.xml from the preview.
We plan to release another preview and will update the versions accordingly (replacing 'preview' with 'beta', for example). Please stay tuned.
Just released 5.9.0-beta2. This will be the last preview before the stable release. We have changed to use the beta terminology and used simple strings instead of macros.
Regrettably, it still didn't work.

That looks like a Pickle issue, I've raised it here: https://github.com/FriendsOfPHP/pickle/issues/202
Was able to successfully install the drivers using Pickle in Ubuntu 18.04. Closing this issue now. Please feel free to reopen if necessary.
Most helpful comment
Thanks @duncan3dc. From my brief testing, changing the two versions from macros to plain strings work for a stable version (tested with the latest 5.8.1). However, installing the latest preview still failed in
VersionParser.php line 176because of some issues with the package.xml from the preview.We plan to release another preview and will update the versions accordingly (replacing 'preview' with 'beta', for example). Please stay tuned.