Damjan Cvetko

Damjan Cvetko

Developer, System Architect, Hacker.

3 minutes read

Derick was nice enough to point out that the soon-to-be-released PHP 8.1 and Xdebug 3.1.0 will need some protocol level adjustments. Since I develop on Windows, building PHP or Xdebug from source isn’t something I did recently. Lets see what we need to do.

First, the nice people of Twitter pointed out prebuilt QA builds can be found on the windows php site: https://windows.php.net/qa#php-8.1

That means half of work was already done. Just download the ZIP and we have PHP 8.1 QA. Xdebug OTOH, we need to build ourselves.

First we download the Development package (SDK to develop PHP extensions) ZIP from the same page and drop it somewhere. Then next to it, checkout Xdebug from https://github.com/xdebug/xdebug.

We now have our extracted folders:


Side note, VS16 stands for Visual Studio 16, that’s actually Visual Studio 2019. Luckily I just happen to have this version installed - as I work with .NET and other Microsoft related tech too.

If we look in the PHP SDK folder we find the familiar phpize.bat. Ok, lets see what happens.

c:\local_disk\zobo\Projects\vscode-php-debug\php>cd xdebug

Rebuilding configure.js
module ...
Now run 'configure --help'

Whoa looks good! Lets try configure! Note: Don’t forget to add the switch to actually build Xdebug.

c:\local_disk\zobo\Projects\vscode-php-debug\php\xdebug>configure.bat --with-xdebug
Saving configure options to config.nice.bat
Checking for cl.exe ...  <not found>
ERROR: Compiler not found

Ok. I might be getting ahead of myself. I checked my VS2019 installation and added the following components

  • MSVC v142 - VS 2019 C++ x64/x86 build tools (latest)
  • Windows 10 SDK (10.0.20348.0)

Before I installed the second one, compilation complained about missing malloc.h.

Let’s try again, and don’t forget to use the x64 Native Tools Command Prompt for VS 2019 start item. Od set paths to compilers in another way.

C:\local_disk\zobo\Projects\vscode-php-debug\php\xdebug>configure.bat --with-xdebug
Saving configure options to config.nice.bat
Checking for cl.exe ...  <in default path>
  Detected compiler Visual C++ 2019
  Detected 64-bit compiler
Checking for link.exe ...  <in default path>
Checking for nmake.exe ...  <in default path>
Checking for lib.exe ...  <in default path>
Checking for bison.exe ...  <not found>
ERROR: bison is required

Wait wait. Bison? What does Xdebug need Bison for?

I check the generated configure.js and found it would also require bison, sed, re2c, zip, lemon, 7za.

Apparently this comes directly from phpize.bat. And since building Xdebug doesn’t require any of those, I simply commented out those ERROR lines.

	var BISON = PATH_PROG('bison');
	if (BISON) {
		var BISONVERS = probe_binary(BISON, "longversion");
	} else {
//		ERROR('bison is required')

	if (!PATH_PROG('sed')) {
//		ERROR('sed is required')



Enabled Zend extensions:
| Extension | Mode   |
| xdebug    | shared |

|                   |                 |
| Build type        | Release         |
| Thread Safety     | No              |
| Compiler          | Visual C++ 2019 |
| Architecture      | x64             |
| Optimization      | PGO disabled    |
| Native intrinsics | SSE2            |
| Static analyzer   | disabled        |

Success! nmake next. A message of EXT xdebug build complete should signal compilation got through and your binary is located under x64\Release\php_xdebug.dll.

Dump that in your ext folder, edit your php.ini (or create one by copying php.ini-development) and add something like this at the end:



Also don’t forget to uncomment

extension_dir = "ext"

If all went well, you have:

php.exe -v
PHP 8.1.0beta2 (cli) (built: Aug  3 2021 14:21:14) (NTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.1.0-dev, Copyright (c) Zend Technologies
    with Xdebug v3.1.0-dev, Copyright (c) 2002-2021, by Derick Rethans

Recent posts

See more