We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

About Phalcon\Config\Adapter\Ini

I've been searching in the docs, but I don't find a way to save changes to an INI file (offsetSet doesn't work), so I supposse I'll just have to use PHP ini functions, right?

edited Feb '15

Once i was looking for same thing and not found it =( at my current project i'm using extended Config class with 2 additional functions:


public function toString(){
    $config = $this->toArray();
    $string = '; config [2.0]'."\n";
    foreach($config as $key => $option){
            $string .= PHP_EOL.'['.$key.']'.PHP_EOL;
            $stringify = http_build_query($option);
            $stringify = str_replace(array('&', '%5B', '%5D', '=', '+'), array('"'.PHP_EOL, '.', '', ' = "', ' '), $stringify).'"';
            $stringify = rawurldecode($stringify).PHP_EOL;
            $string .= $stringify;
            $string .= $key.' = "'.$option.'"'.PHP_EOL;

    return trim($string, PHP_EOL);

public function save($file){
    $file = new IO\Adapter\File($file);
    return $file->putContents($this->toString());


Not perfect, but i'm satisfied with it. Hope it can help you.


I thank your effort, but I'm doing this just one time (for now). It's more quick using PHP functions directly.