Yaml with codeigniter

If you are using large number of configuration in  your website then how do you process that configuration i mean where you stored that configuration settings and how to get that configuration. I think many of the people goes to the database to store the configuration setting but it may increases the database load.

So that today we gonna to learn how to handle the configuration settings in codeigniter. One solution is to use the Spyc Yaml.

What is Spyc? 

Spyc is a YAML loader/dumper written in pure PHP. Given a YAML document, Spyc will return an array that you can use however you see fit. Given an array, Spyc will return a string which contains a YAML document built from your data.

What is Yaml?

YAML is an amazingly human friendly and strikingly versatile data serialization language which can be used for log files, config files, custom protocols, the works. For more information, see http://www.yaml.org.

Yaml file looks like:

with file extension of YML. Even file processing better than load and get the data from database. After long search i found on yaml library for codeigniter and it quite easy to use. This library should return associated array.

Library : http://getsparks.org/packages/yaml/versions/HEAD/show

Installation:

This library package has two folder one is config and another one is libraries folder. Copy the “yaml” library files from libraries folder and paste it to in your codeigniter application libraries folder.

You can load this library by using

There are two ways to process the yaml

  • To parse YAML as String
  • To parse a Yaml file

    •  

How to dump your array to yaml string:

That is it. Still i am not tried with this library but i could be useful for some other people.

Thank you