Phalcon\Config\Loader::load PHP Method

load() public static method

Load config from file extension dynamical
public static load ( string $filePath ) : Phalcon\Config
$filePath string
return Phalcon\Config
    public static function load($filePath)
    {
        if (!is_file($filePath)) {
            throw new Exception('Config file not found');
        }
        $extension = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
        switch ($extension) {
            case 'ini':
                return new Ini($filePath);
            case 'json':
                return new Json($filePath);
            case 'php':
            case 'php5':
            case 'inc':
                return new Php($filePath);
            case 'yml':
            case 'yaml':
                return new Yaml($filePath);
            default:
                throw new Exception('Config adapter for .' . $extension . ' files is not support');
        }
    }

Usage Example

Beispiel #1
0
 /**
  * @expectedException \Phalcon\Config\Exception
  * @expectedExceptionMessage Config adapter for .txt files is not support
  */
 public function testLoadUnsupportedConfigFile()
 {
     $file = INCUBATOR_FIXTURES . 'Config/config.txt';
     ConfigLoader::load($file);
 }
Loader