PHP Classes

File: examples/example.php

Recommend this page to a friend!
  Classes of Vurghus Minar   PHP Configuration Loader   examples/example.php   Download  
File: examples/example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Configuration Loader
Load configuration from YAML files into arrays
Author: By
Last change:
Date: 7 years ago
Size: 1,145 bytes
 

Contents

Class file image Download
<?php
require dirname(__DIR__) . '/vendor/autoload.php';

$config = array(
'test_number' => 10, 'test' => 'bla'
);

$config_from_array = new \Am\Config\Config($config, 0, false);
echo
$config_from_array->debug;
var_dump($config_from_array);

echo
"<br/><br/><hr><br/><br/>";



$config_file = array(
   
dirname(__DIR__) . '/examples/configs/config.yaml',
   
dirname(__DIR__) . '/examples/configs/config-2.yaml',
    array(
       
'hotel'=>'5 star',
       
'rooms'=> 10
   
)
);
$config_from_file = new \Am\Config\Config($config_file,1,true);

var_dump($config_from_file);

echo
"<br/><br/><hr><br/><br/>";



$config_file_with_error = dirname(__DIR__) . '/examples/configs/config-contains-mistakes.yaml';
$config_from_file_with_error = new \Am\Config\Config($config_file_with_error,0,true);

var_dump($config_from_file_with_error);

echo
"<br/><br/><hr><br/><br/>";



$config_arrays_only = array(
    array(
       
'test_number1' => 10,
       
'test1' => 'bla'
   
),
    array(
       
'hotel1'=>'5 star',
       
'rooms1'=> 10
   
)
);

$config_from__arrays_only = new \Am\Config\Config($config_arrays_only, 1, false);
echo
$config_from__arrays_only->debug;
var_dump($config_from__arrays_only);