Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing PHP YAML Extension with XAMPP on Windows

Hey folks I am currently doing some work on PhP that requires me to parse a YAML file by using the yaml_parse_file() function. I am still new to the language and all so when I tried using that function on my unmodified XAMPP server on Windows I got the error 'function not found'. After some research I found out that you are actually supposed to install extensions on your php installation to be able to use that function. http://php.net/manual/en/yaml.setup.php this link details the installation process and I have read through it however I am confused in regards to the installation procedure. The above link states that there is not a DLL package available for download however a comment direct to this link http://pecl.php.net/package/yaml where you can clearly see a DLL Package for YAML Parser. My question is if you could please walk me through how to go about this installation procedure on a Windows Machine using XAMPP.

Edit: https://code.google.com/p/php-yaml/wiki/InstallingWithPecl this link might offer you more insight on this topic although I fail to understand how it all works :(

Edit2: I have tried to download the DLL given on the above link and add it to my php/ext folder and add an entry in php.ini extension=php_yaml.dll but when I try to test if my extension has been loaded by the following script, I get an error.

<?php
if (extension_loaded(yaml))
  echo "yaml loaded :)";
else
  echo "something is wrong :(";
?>
like image 640
shadoweye14 Avatar asked Nov 25 '14 09:11

shadoweye14


People also ask

How to install PHP extensions on Windows?

On Windows, you have two ways to load a PHP extension: either compile it into PHP, or load the DLL. Loading a pre-compiled extension is the easiest and preferred way. To load an extension, you need to have it available as a ". dll" file on your system.


2 Answers

With a bit of help from the readers I seem to have narrowed down the steps to accomplish this.

  1. Download the latest YAML DLL Package
  2. Unzip the files
  3. Move the php_yaml.dll file to xampp/php/ext folder
  4. Open your php.ini in xampp/php and add the line extension=php_yaml.dll, save and exit
  5. Now move the yaml.dll file from the zip folder contents and move it to the xampp/apache/bin folder
  6. Close and restart your XAMPP Servers
  7. Load a php script echo phpinfo();
  8. Search the string yaml on the page. If it says Enabled then your YAML Extension is working.
like image 165
shadoweye14 Avatar answered Sep 23 '22 06:09

shadoweye14


As of 2018.04.17, Windows 10, Step 5 above is nonsensical: there is no yaml.dll available.

My solution was to copy the php.ini file from the php folder into the location Apache was looking into for its use of php. phpinfo() told me that was c:\windows (which you need admin rights to write into)

Earlier I had just copied php_yaml.dll into the apache dll folder. I have left it there maybe it's part of the solution too.

PS. Thanks &^%* admins for deleting my earlier call for help. THAT didn't help.

like image 45
Thibault Jamme Avatar answered Sep 25 '22 06:09

Thibault Jamme