phpc++windowsyamlpecl

How do I build the YAML PECL extension for Windows when there isn't already a DLL available?


I have PHP 8.2.4 installed on my Windows machine and I would like to enable the YAML extension. The instructions that I have followed in the past are to download the the Windows DLL from the PECL YAML site: https://pecl.php.net/package/yaml

However, the site (at this point in time) doesn't have a built DLL for PHP 8.2.

I tried following the steps provided in the following document but it wasn't generating the correct DLL: https://wiki.php.net/internals/windows/stepbystepbuild

When I tried copying the DLL into the php extensions folder and enabling it in the php.ini, it gives an error for that extension.


Solution

  • Here's what I did to compile a compatible version using the following site as a guide: https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2#building_pecl_extensions_with_phpize

    1. Install Virtual Studio Build Tools 2019 Components
      • Windows Universal C Runtime
      • C++ Build Tools core features
      • MSVC v142 - VS 2019 C++ x64/x86 build tools (Latest)
      • C++ CMake tools for Windows
      • Testing tools core features - Build Tools
      • C++ v14.29 (16.10) MFC for v142 build tools (x86 & x64)
      • Windows 10 SDK (10.0.20348.0)
    2. Download Windows PHP and Windows PHP Development Package (on download page) https://windows.php.net/download/
    3. Download libyaml from PHP pecl deps https://windows.php.net/downloads/pecl/deps/
    4. Create a build folder for libraries (D:\build)
    5. Extract the Windows PHP Development Package into that folder
    6. Extract the libyaml into that folder as "libyaml"
    7. Clone the yaml repo https://github.com/php/pecl-file_formats-yaml.git into that folder
    8. Clone the Microsoft PHP binary tools https://github.com/Microsoft/php-sdk-binary-tools.git into that folder and checkout the latest tag (php-sdk-2.2.0)
    9. Open the visual studio app, x64 Native Tools Command Prompt for VS 2019 (you can find it in the start menu; search for native)
    10. Change directory to the php-sdk-binary-tools folder and run phpsdk-vs16-x64.bat
    11. Set the path to include the PHP that you download and the development package folders on the path: set PATH=D:\php-8.2.4;D:\build\php-8.2.4-devel-vs16-x64;%PATH%
    12. Change directory to the pecl folder "pecl-file_formats-yaml"
    13. Run phpize
    14. Then run configure --with-yaml --with-php-build=..\libyaml
    15. Run nmake

    The yaml dll file will be located in the subdirectory, x64\Release as php_yaml.dll