Yaml library |
[eluser]OliverHR[/eluser]
Hello everybody, I post in the wiki a wrapper to user sfYaml library with codeigniter. Wiki and file link: http://codeigniter.com/wiki/Yaml_with_Symfony_Yaml/ I hope this may be useful to someone, Any comments are welcome. OliverHR.
[eluser]OliverHR[/eluser]
Wrapper (codeigniter library) and sfyaml. -ci_sfyaml.zip Tested with codeigniter versions: - 1.7.2 To load this library: Code: $this->load->library('yaml'); [h3]Method Summary[/h3] load Loads YAML into a PHP array. * @param string $input Path of YAML file or string containing YAML Code: $input = APPPATH . 'directory/filename.yml'; dump Dumps a PHP array to a YAML string. * @param integer $inline - The level where you switch to inline YAML Code: $this->yaml->dump($array, $inline); // return string Code: $array = array( Returns this YAML string representing the original PHP array: Code: one: write_yml Save a file with a YAML string Dumped from a PHP array. * @param string $file File name * @param array $array PHP array * @param string $path Optional specific directory path to save the file Code: $this->yaml->write_yml($file, $array, $path = ''); Code: $path = APPPATH.'fixtures'; Code: $file = APPPATH.'fixtures/temp.yml'; getSpecVersion Gets the YAML specification version to use. Code: $this->yaml->getSpecVersion() // return string setSpecVersion Sets the YAML specification version to use. Code: $this->yaml->setSpecVersion($version) // return void Note: Default Yaml specification version is 1.2
[eluser]jpi[/eluser]
Nice one. I like the approach, use the already existing excellent libraries from several frameworks, wrap them, and use them in CI.
[eluser]OliverHR[/eluser]
Yes extend codeigniter capabilities is quite easy.
[eluser]ideogroup[/eluser]
Hi does it implements all YAML specs (http://en.wikipedia.org/wiki/YAML) ? I've done: $this->load->library('yaml'); $input = APPPATH . '/application/yaml/admin_menu.yml'; print_r($this->yaml->load($input)); // return array but it returns me only: /application/yaml/admin_menu.yml Why? Thanks
[eluser]OliverHR[/eluser]
@ideogroup, "APPPATH" refers to your CI application directory, then you must fix this line: Code: $input = APPPATH . '/application/yaml/admin_menu.yml'; To: Code: $input = APPPATH . 'yaml/admin_menu.yml';
|
Welcome Guest, Not a member yet? Register Sign In |