ConfigServiceProvider icon indicating copy to clipboard operation
ConfigServiceProvider copied to clipboard

Support for NEON

Open feamsr00 opened this issue 9 years ago • 0 comments

Hi There,

May I suggest adding support for config.neon files?

https://ne-on.org/

For miscellaneous reasons, I am unable to use the pull feature here. However in light of its brevity I have simply included the driver below:

<?php
namespace Igorw\Silex;

use Nette\Neon;

class NeonConfigDriver implements ConfigDriver
{
    public function load($filename)
    {
        if (!class_exists('Neon\\Neon')) {
            throw new \RuntimeException('Unable to read neon as the Neon Parser is not installed.');
        }
        $config = Neon\Neon::decode(file_get_contents($filename));
        return $config ?: array();
    }
    public function supports($filename)
    {
        return (bool) preg_match('#\.neon(\.dist)?$#', $filename);
    }
}

feamsr00 avatar Jun 10 '16 20:06 feamsr00