Alexey Zakhlestin's Blog

Programming for Mac and Web

Ini2yaml in PHP

Permalink

If you still use INI file for some of your PHP-projects configuration, I guess it is time for you to migrade to YAML which is more flexible and has way more expressiveness. Here is a little tool to help you in migration process

<?php
    require "<a href="http://spyc.sourceforge.net/">Spyc.php</a>";
    if ($argc != 3)
        die("I need 2 parameters: in_file.ini, out_file.yml\n");

    if (!is_readable($argv[1]))
        die("can't read from ".$argv[1]."\n");

    $ini = parse_ini_file($argv[1], true);
    file_put_contents($argv[2], Spyc::YAMLDump($ini));

Comments