public static function readConfigFile($file = self::DEFAULT_CONFIG_FILE)
    {
        if (!is_string($file)) {
            throw new InvalidArgumentException('The config file path must be a string, type passed "'.gettype($file).'".');
        }

        $baseDir = realpath(dirname($file));
        $searchDirs = array(
            $baseDir.'/',
            $baseDir.'/../',
            $baseDir.'/../../',
            $baseDir.'/config/',
            $baseDir.'/../config/',
            $baseDir.'/../../config/'
        );

        $filename = basename($file);

        $configFile = null;
        foreach ($searchDirs as $dir) {
            if (realpath($dir.$filename) and is_readable($dir.$filename)) {
                $configFile = realpath($dir.$filename);
                break;
            }
        }

        if (is_null($configFile) and $file !== self::DEFAULT_CONFIG_FILE) {
            throw new InvalidArgumentException('The config file "'.$file.'" cannot be found or read.');
        }

        if (!$configFile) {
            return static::$config;
        }

        // Try to parse the contents
        try {
            $yaml = Yaml\Yaml::parse(file_get_contents($configFile));
        } catch (Yaml\Exception\ParseException $e) {
            throw new Exception('Unable to parse the config file: '.$e->getMessage());
        }

        return static::$config = $yaml;
    }
public static function readConfigFile($file = self::DEFAULT_CONFIG_FILE)
    {
        if (!is_string($file)) {
            throw new InvalidArgumentException('The config file path must be a string, type passed "'.gettype($file).'".');
        }

        $baseDir = realpath(dirname($file));
        $searchDirs = array(
            $baseDir.'/',
            $baseDir.'/../',
            $baseDir.'/../../',
            $baseDir.'/config/',
            $baseDir.'/../config/',
            $baseDir.'/../../config/'
        );

        $filename = basename($file);

        $configFile = null;
        foreach ($searchDirs as $dir) {
            if (realpath($dir.$filename) and is_readable($dir.$filename)) {
                $configFile = realpath($dir.$filename);
                break;
            }
        }

        if (is_null($configFile) and $file !== self::DEFAULT_CONFIG_FILE) {
            throw new InvalidArgumentException('The config file "'.$file.'" cannot be found or read.');
        }

        if (!$configFile) {
            return static::$config;
        }

        // Try to parse the contents
        try {
            $yaml = Yaml\Yaml::parse(file_get_contents($configFile));
        } catch (Yaml\Exception\ParseException $e) {
            throw new Exception('Unable to parse the config file: '.$e->getMessage());
        }

        return static::$config = $yaml;
    }
public static function readConfigFile ( $ file = self :: DEFAULT_CONFIG_FILE ) { if ( ! is_string ( $ file ) ) { throw new InvalidArgumentException ( 'The config file path must be a string, type passed "' . gettype ( $ file ) . '".' ) ; } $ baseDir = realpath ( dirname ( $ file ) ) ; $ searchDirs = array ( $ baseDir . '/' , $ baseDir . '/../' , $ baseDir . '/../../' , $ baseDir . '/config/' , $ baseDir . '/../config/' , $ baseDir . '/../../config/' ) ; $ filename = basename ( $ file ) ; $ configFile = null ; foreach ( $ searchDirs as $ dir ) { if ( realpath ( $ dir . $ filename ) and is_readable ( $ dir . $ filename ) ) { $ configFile = realpath ( $ dir . $ filename ) ; break ; } } if ( is_null ( $ configFile ) and $ file !== self :: DEFAULT_CONFIG_FILE ) { throw new InvalidArgumentException ( 'The config file "' . $ file . '" cannot be found or read.' ) ; } if ( ! $ configFile ) { return static :: $ config ; } // Try to parse the contents try { $ yaml = Yaml \ Yaml :: parse ( file_get_contents ( $ configFile ) ) ; } catch ( Yaml \ Exception \ ParseException $ e ) { throw new Exception ( 'Unable to parse the config file: ' . $ e -> getMessage ( ) ) ; } return static :: $ config = $ yaml ; }
Reads data from a config file

@param  string $file The config file path
@return array
Reads data from a config file