Software Engineer

enabling php syck library on centos

· by jsnby · Read in about 1 min · (174 Words)
Computers

I’ve been working with Puppet lately as a configuration management utility. It is written in Ruby, and it appears that Ruby developers love YAML. I’m working on a script to parse some of the YAML reports into something intelligible. I started by installing the php-syck package to enable me to parse YAML;

sudo yum install php-syck
sudo /etc/init.d/httpd restart

This installed php-syck-0.55-4.el5.rf on my server. The, I wrote up some test code. I have a file with data in YAML format in it. I just wanted to load the file into memory, parse the data, then dump the resulting object:

<?php
$file = '/path/to/file.yaml';

$fh = fopen($file, 'r');
$theData = rtrim(fread($fh, filesize($file)));
fclose($fh);

$data = syck_load($theData);
print_r($data);

The problem was that I was getting an error: PHP Fatal error: Call to undefined function syck_load() in

Ok…I installed the package, so what gives? Scratched my head for another minute, then it dawned on me….I bet the rpm packager forgot the /etc/php.d/syck.ini file. I added a file called /etc/php.d/syck.ini with the following contents:

extension=syck.so

Restart apache:

sudo /etc/init.d/httpd restart

The function syck_load was present. Reloaded my other page and all was well.