YAML is used in a wide array of applications, whether in Ansible scripts or elsewhere. In general, it is easier to write YAML than to write correct JSON on your keyboard. If you need to read and parse YAML on your Windows computer, you may find it necessary to install LibYAML to have access to useful functions like yaml_parse().
Uncaught Error: Call to undefined function yaml_parse() in yml2xml.php:5
This post will explain how you can add LibYAML to your Windows XAMPP installation. This will also resolve the error in case the function is not yet present on your system. However, this is not limited to XAMPP, as the process is similar if you run a Windows server with PHP.
First, we need the DLL file that will be loaded into the PHP extensions. In my case, I’m running the latest XAMPP 8.2.12, so I need the DLL for PHP 8.2.12.
To download the YAML package DLL, I need to go to the PECL website.
In the download column, there is a DDL link. I will click the DDL link for the newest version.
Here I go with the thread-safe x64 version of the file, selecting PHP 8.2, which matches the PHP version bundled with XAMPP.
Then copy the downloaded and extracted file (php_yaml.dll) into the PHP extension folder (C:\xampp\php\ext).
Next, I need to update the php.ini file to instruct it to load the extension on startup. The Config button on the Apache module in the XAMPP Control Panel can help you find the correct file. In my case, the file is located at C:\xampp\php\php.ini.
Add the following line to the php.ini; the .dll file extension is not necessary.
extension=php_yaml
Now you need to restart the Apache module. If everything went well, you will now find that Apache has restarted and the module is loaded if you check it with phpinfo().