PHP Classes
elePHPant
Icontem

PHP Configuration Loader: Load configuration from YAML files into arrays

Recommend this page to a friend!
  Info   View files Example   View files View files (208)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-09-26 (1 year ago) RSS 2.0 feedNot enough user ratingsTotal: 84 All time: 9,207 This week: 440Up
Version License PHP version Categories
php-configuration-lo 1.0.0Custom (specified...5PHP 5, Files and Folders, Configuration
Description Author

This class can load configuration from YAML files into arrays.

It can load a given configuration file in YAML format and extract the values defined in it into arrays.

Configuration value names with space characters are converted to underscores.

  Performance   Level  
Name: Vurghus Minar <contact>
Classes: 1 package by
Country: United Kingdom United Kingdom

Details

PHP Configuration Loader Class

About

The PHP configuration loader class helps the management and loading of application configuration through arrays or Yaml configuration files.

Installation

Via Composer:

composer require am/config

Or simply download the code and add to your project.

Example Use

config.yaml

root_path: C:/xampp/htdocs
base_url: /
directories:
  controllers: controllers
  models: models
  views: views
  core: core
test_number: 10

config-2.yaml

this name: config 2
this number: 10
test_number: 10

<?php
require dirname(__DIR__) . '/vendor/autoload.php';

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

var_dump($config);

Resulting dump:

<?php
object(Am\Config\Config)[2]
  public 'config' => 
    array (size=3)
      0 => string 'C:\xampp\htdocs\projects\composer\config/examples/configs/config.yaml' (length=69)
      1 => string 'C:\xampp\htdocs\projects\composer\config/examples/configs/config-2.yaml' (length=71)
      2 => 
        array (size=2)
          'hotel' => string '5 star' (length=6)
          'rooms' => int 10
  public 'src' => int 1
  public 'debug' => boolean true
  public 'root_path' => string 'C:/xampp/htdocs' (length=15)
  public 'base_url' => string '/' (length=1)
  public 'directories' => 
    array (size=4)
      'controllers' => string 'controllers' (length=11)
      'models' => string 'models' (length=6)
      'views' => string 'views' (length=5)
      'core' => string 'core' (length=4)
  public 'test_number' => int 10
  public 'this_name' => string 'config 2' (length=8)
  public 'this_number' => int 10
  public 'hotel' => string '5 star' (length=6)
  public 'rooms' => int 10

You can now retrieve application configuration within your file as public vars as follows:


echo $config->hotel; //returns "5 star"

foreach($config->directories as $dir){
	echo $dir;
}

Additional Resources

How to Install LibYAML

To allow PHP to parse YAML files, you will require php libyaml available.

https://github.com/LegendOfMCPE/LoM-CMS/wiki/How-to-Install-LibYAML

https://stackoverflow.com/questions/27122701/installing-php-yaml-extension-with-xampp-on-windows

Note for Windows Xampp users, it is useful to copy yaml.dll to your xampp php folder as well to allow it to run in CLI (important mainly while running tests).

  Files folder image Files  
File Role Description
Files folder imagedocs (1 directory)
Files folder imageexamples (1 file, 1 directory)
Files folder imagesrc (1 file)
Files folder imagetests (1 file, 1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpdoc.dist.xml Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file readme.md Doc. Documentation

  Files folder image Files  /  docs  
File Role Description
Files folder imageapi (7 files, 11 directories)

  Files folder image Files  /  docs  /  api  
File Role Description
Files folder imageclasses (1 file)
Files folder imagecss (10 files, 1 directory)
Files folder imagefiles (2 files)
Files folder imagefont (1 file)
Files folder imagegraphs (1 file)
Files folder imageimages (12 files, 1 directory)
Files folder imageimg (7 files, 2 directories)
Files folder imagejs (25 files, 3 directories)
Files folder imagenamespaces (3 files)
Files folder imagepackages (3 files)
Files folder imagereports (3 files)
  Accessible without login Plain text file .htaccess Data Auxiliary data
  Accessible without login Plain text file checkstyle.xml Data Auxiliary data
  Accessible without login HTML file deprecated.html Doc. Documentation
  Accessible without login HTML file errors.html Doc. Documentation
  Accessible without login HTML file graph_class.html Doc. Documentation
  Accessible without login HTML file index.html Doc. Documentation
  Accessible without login HTML file markers.html Doc. Documentation

  Files folder image Files  /  docs  /  api  /  classes  
File Role Description
  Accessible without login HTML file Am.Config.Config.html Doc. Documentation

  Files folder image Files  /  docs  /  api  /  css  
File Role Description
Files folder imagephpdocumentor-clean-icons (2 files, 1 directory)
  Accessible without login Plain text file bootstrap-combined.no-icons.min.css Data Auxiliary data
  Accessible without login Plain text file bootstrap-responsive.css Data Auxiliary data
  Accessible without login Plain text file bootstrap-responsive.min.css Data Auxiliary data
  Accessible without login Plain text file bootstrap.css Data Auxiliary data
  Accessible without login Plain text file bootstrap.min.css Data Auxiliary data
  Accessible without login Plain text file font-awesome.min.css Data Auxiliary data
  Accessible without login Plain text file jquery.iviewer.css Data Auxiliary data
  Accessible without login Plain text file prettify.css Data Auxiliary data
  Accessible without login Plain text file prism.css Data Auxiliary data
  Accessible without login Plain text file template.css Data Auxiliary data

  Files folder image Files  /  docs  /  api  /  css  /  phpdocumentor-clean-icons  
File Role Description
Files folder imagefonts (2 files)
  Accessible without login Plain text file lte-ie7.js Data Auxiliary data
  Accessible without login Plain text file style.css Data Auxiliary data

  Files folder image Files  /  docs  /  api  /  css  /  phpdocumentor-clean-icons  /  fonts  
File Role Description
  Accessible without login Plain text file phpdocumentor-clean-icons.dev.svg Data Auxiliary data
  Accessible without login Plain text file phpdocumentor-clean-icons.svg Data Auxiliary data

  Files folder image Files  /  docs  /  api  /  files  
File Role Description
  Accessible without login HTML file Config.html Doc. Documentation
  Accessible without login Plain text file Config.php.txt Doc. Documentation

  Files folder image Files  /  docs  /  api  /  font  
File Role Description
  Accessible without login Plain text file fontawesome-webfont.svg Data Auxiliary data

  Files folder image Files  /  docs  /  api  /  graphs  
File Role Description
  Accessible without login HTML file class.html Doc. Documentation

  Files folder image Files  /  docs  /  api  /  images  
File Role Description
Files folder imageiviewer (8 files)
  Accessible without login Image file apple-touch-icon-114x114.png Icon Icon image
  Accessible without login Image file apple-touch-icon-72x72.png Icon Icon image
  Accessible without login Image file apple-touch-icon.png Icon Icon image
  Accessible without login Plain text file custom-icons.svg Data Auxiliary data
  Accessible without login Image file favicon.ico Data Auxiliary data
  Accessible without login Image file hierarchy-item.png Icon Icon image
  Accessible without login Image file icon-class-13x13.png Icon Icon image
  Accessible without login Plain text file icon-class.svg Data Auxiliary data
  Accessible without login Image file icon-interface-13x13.png Icon Icon image
  Accessible without login Plain text file icon-interface.svg Data Auxiliary data
  Accessible without login Image file icon-trait-13x13.png Icon Icon image
  Accessible without login Plain text file icon-trait.svg Data Auxiliary data

  Files folder image Files  /  docs  /  api  /  images  /  iviewer  
File Role Description
  Accessible without login Image file grab.cur Data Auxiliary data
  Accessible without login Image file hand.cur Data Auxiliary data
  Accessible without login Image file iviewer.rotate_left.png Icon Icon image
  Accessible without login Image file iviewer.rotate_right.png Icon Icon image
  Accessible without login Image file iviewer.zoom_fit.png Icon Icon image
  Accessible without login Image file iviewer.zoom_in.png Icon Icon image
  Accessible without login Image file iviewer.zoom_out.png Icon Icon image
  Accessible without login Image file iviewer.zoom_zero.png Icon Icon image

  Files folder image Files  /  docs  /  api  /  img  
File Role Description
Files folder imageicons (22 files)
Files folder imageiviewer (12 files)
  Accessible without login Image file apple-touch-icon-114x114.png Icon Icon image
  Accessible without login Image file apple-touch-icon-72x72.png Icon Icon image
  Accessible without login Image file apple-touch-icon.png Icon Icon image
  Accessible without login Image file favicon.ico Data Auxiliary data
  Accessible without login Image file glyphicons-halflings-white.png Icon Icon image
  Accessible without login Image file glyphicons-halflings.png Icon Icon image
  Accessible without login Image file loader.gif Icon Icon image

  Files folder image Files  /  docs  /  api  /  img  /  icons  
File Role Description
  Accessible without login Image file arrow_down.png Icon Icon image
  Accessible without login Image file arrow_right.png Icon Icon image
  Accessible without login Image file class.png Icon Icon image
  Accessible without login Image file constant.png Icon Icon image
  Accessible without login Image file favicon.ico Data Auxiliary data
  Accessible without login Image file file-php.png Icon Icon image
  Accessible without login Image file file.gif Icon Icon image
  Accessible without login Image file folder.gif Icon Icon image
  Accessible without login Image file function.png Icon Icon image
  Accessible without login Image file icon-folder-open-big.png Icon Icon image
  Accessible without login Image file icon-th-big.png Icon Icon image
  Accessible without login Plain text file icon_template.svg Data Auxiliary data
  Accessible without login Image file interface.png Icon Icon image
  Accessible without login Image file method.png Icon Icon image
  Accessible without login Image file ok.png Icon Icon image
  Accessible without login Image file property.png Icon Icon image
  Accessible without login Image file search.gif Icon Icon image
  Accessible without login Image file variable.png Icon Icon image
  Accessible without login Image file view_source.png Icon Icon image
  Accessible without login Image file visibility_private.png Icon Icon image
  Accessible without login Image file visibility_protected.png Icon Icon image
  Accessible without login Image file visibility_public.png Icon Icon image

  Files folder image Files  /  docs  /  api  /  img  /  iviewer  
File Role Description
  Accessible without login Image file grab.cur Data Auxiliary data
  Accessible without login Image file hand.cur Data Auxiliary data
  Accessible without login Image file iviewer.rotate_left.png Icon Icon image
  Accessible without login Image file iviewer.rotate_right.png Icon Icon image
  Accessible without login Image file iviewer.zoom_fit.png Icon Icon image
  Accessible without login Image file iviewer.zoom_fit2.gif Icon Icon image
  Accessible without login Image file iviewer.zoom_in.png Icon Icon image
  Accessible without login Image file iviewer.zoom_in2.gif Icon Icon image
  Accessible without login Image file iviewer.zoom_out.png Icon Icon image
  Accessible without login Image file iviewer.zoom_out2.gif Icon Icon image
  Accessible without login Image file iviewer.zoom_zero.png Icon Icon image
  Accessible without login Image file iviewer.zoom_zero2.gif Icon Icon image

  Files folder image Files  /  docs  /  api  /  js  
File Role Description
Files folder imagejqplot (8 files, 1 directory)
Files folder imageprettify (19 files)
Files folder imageui (1 directory)
  Accessible without login Plain text file bootstrap.js Data Auxiliary data
  Accessible without login Plain text file bootstrap.min.js Data Auxiliary data
  Accessible without login Plain text file html5.js Data Auxiliary data
  Accessible without login Plain text file jquery-1.11.0.min.js Data Auxiliary data
  Accessible without login Plain text file jquery-1.4.2.min.js Data Auxiliary data
  Accessible without login Plain text file jquery-1.7.1.min.js Data Auxiliary data
  Accessible without login Plain text file jquery-ui-1.8.2.custom.min.js Data Auxiliary data
  Accessible without login Plain text file jquery.cookie.js Data Auxiliary data
  Accessible without login Plain text file jquery.dotdotdot-1.5.9.js Data Auxiliary data
  Accessible without login Plain text file jquery.dotdotdot-1.5.9.min.js Data Auxiliary data
  Accessible without login Plain text file jquery.iviewer.js Data Auxiliary data
  Accessible without login Plain text file jquery.iviewer.min.js Data Auxiliary data
  Accessible without login Plain text file jquery.mousewheel.js Data Auxiliary data
  Accessible without login Plain text file jquery.mousewheel.min.js Data Auxiliary data
  Accessible without login Plain text file jquery.panzoom.js Data Auxiliary data
  Accessible without login Plain text file jquery.smooth-scroll.js Data Auxiliary data
  Accessible without login Plain text file jquery.splitter.js Data Auxiliary data
  Accessible without login Plain text file jquery.tools.min.js Data Auxiliary data
  Accessible without login Plain text file jquery.treeview.js Data Auxiliary data
  Accessible without login Plain text file jquery.xml2json.js Data Auxiliary data
  Accessible without login Plain text file menu.js Data Auxiliary data
  Accessible without login Plain text file prism.min.js Data Auxiliary data
  Accessible without login Plain text file sidebar.js Data Auxiliary data
  Accessible without login Plain text file SVGPan.js Data Auxiliary data
  Accessible without login Plain text file template.js Data Auxiliary data

  Files folder image Files  /  docs  /  api  /  js  /  jqplot  
File Role Description
Files folder imageplugins (30 files)
  Accessible without login Plain text file changes.txt Doc. Documentation
  Accessible without login Plain text file copyright.txt Doc. Documentation
  Accessible without login Plain text file excanvas.min.js Data Auxiliary data
  Accessible without login Plain text file gpl-2.0.txt Doc. Documentation
  Accessible without login Plain text file jquery.jqplot.min.css Data Auxiliary data
  Accessible without login Plain text file jquery.jqplot.min.js Data Auxiliary data
  Accessible without login Plain text file MIT-LICENSE.txt Doc. Documentation
  Accessible without login Plain text file README.txt Doc. Documentation

  Files folder image Files  /  docs  /  api  /  js  /  jqplot  /  plugins  
File Role Description
  Accessible without login Plain text file jqplot.barRenderer.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.BezierCurveRenderer.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.blockRenderer.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.bubbleRenderer.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.canvasAxisLabelRenderer.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.canvasAxisTickRenderer.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.canvasOverlay.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.canvasTextRenderer.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.categoryAxisRenderer.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.ciParser.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.cursor.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.dateAxisRenderer.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.donutRenderer.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.dragable.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.enhancedLegendRenderer.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.funnelRenderer.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.highlighter.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.json2.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.logAxisRenderer.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.mekkoAxisRenderer.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.mekkoRenderer.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.meterGaugeRenderer.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.mobile.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.ohlcRenderer.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.pieRenderer.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.pointLabels.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.pyramidAxisRenderer.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.pyramidGridRenderer.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.pyramidRenderer.min.js Data Auxiliary data
  Accessible without login Plain text file jqplot.trendline.min.js Data Auxiliary data

  Files folder image Files  /  docs  /  api  /  js  /  prettify  
File Role Description
  Accessible without login Plain text file lang-apollo.js Data Auxiliary data
  Accessible without login Plain text file lang-clj.js Data Auxiliary data
  Accessible without login Plain text file lang-css.js Data Auxiliary data
  Accessible without login Plain text file lang-go.js Data Auxiliary data
  Accessible without login Plain text file lang-hs.js Data Auxiliary data
  Accessible without login Plain text file lang-lisp.js Data Auxiliary data
  Accessible without login Plain text file lang-lua.js Data Auxiliary data
  Accessible without login Plain text file lang-ml.js Data Auxiliary data
  Accessible without login Plain text file lang-n.js Data Auxiliary data
  Accessible without login Plain text file lang-proto.js Data Auxiliary data
  Accessible without login Plain text file lang-scala.js Data Auxiliary data
  Accessible without login Plain text file lang-sql.js Data Auxiliary data
  Accessible without login Plain text file lang-tex.js Data Auxiliary data
  Accessible without login Plain text file lang-vb.js Data Auxiliary data
  Accessible without login Plain text file lang-vhdl.js Data Auxiliary data
  Accessible without login Plain text file lang-wiki.js Data Auxiliary data
  Accessible without login Plain text file lang-xq.js Data Auxiliary data
  Accessible without login Plain text file lang-yaml.js Data Auxiliary data
  Accessible without login Plain text file prettify.min.js Data Auxiliary data

  Files folder image Files  /  docs  /  api  /  js  /  ui  
File Role Description
Files folder image1.10.4 (1 file)

  Files folder image Files  /  docs  /  api  /  js  /  ui  /  1.10.4  
File Role Description
  Accessible without login Plain text file jquery-ui.min.js Data Auxiliary data

  Files folder image Files  /  docs  /  api  /  namespaces  
File Role Description
  Accessible without login HTML file Am.Config.html Doc. Documentation
  Accessible without login HTML file Am.html Doc. Documentation
  Accessible without login HTML file default.html Doc. Documentation

  Files folder image Files  /  docs  /  api  /  packages  
File Role Description
  Accessible without login HTML file Am.Config.html Doc. Documentation
  Accessible without login HTML file Am.html Doc. Documentation
  Accessible without login HTML file default.html Doc. Documentation

  Files folder image Files  /  docs  /  api  /  reports  
File Role Description
  Accessible without login HTML file deprecated.html Doc. Documentation
  Accessible without login HTML file errors.html Doc. Documentation
  Accessible without login HTML file markers.html Doc. Documentation

  Files folder image Files  /  examples  
File Role Description
Files folder imageconfigs (3 files)
  Accessible without login Plain text file example.php Example Example script

  Files folder image Files  /  examples  /  configs  
File Role Description
  Accessible without login Plain text file config-2.yaml Data Auxiliary data
  Accessible without login Plain text file config-contains-mistakes.yaml Data Auxiliary data
  Accessible without login Plain text file config.yaml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
  Plain text file Config.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder image_reports (3 directories)
  Plain text file ConfigTest.php Class Class source

  Files folder image Files  /  tests  /  _reports  
File Role Description
Files folder imagecoverage (3 files, 3 directories)
Files folder imagelogs (1 file)
Files folder imagetestdox (1 file)

  Files folder image Files  /  tests  /  _reports  /  coverage  
File Role Description
Files folder image.css (3 files)
Files folder image.fonts (1 file)
Files folder image.js (8 files)
  Accessible without login HTML file Config.php.html Doc. Documentation
  Accessible without login HTML file dashboard.html Doc. Documentation
  Accessible without login HTML file index.html Doc. Documentation

  Files folder image Files  /  tests  /  _reports  /  coverage  /  .css  
File Role Description
  Accessible without login Plain text file bootstrap.min.css Data Auxiliary data
  Accessible without login Plain text file nv.d3.min.css Data Auxiliary data
  Accessible without login Plain text file style.css Data Auxiliary data

  Files folder image Files  /  tests  /  _reports  /  coverage  /  .fonts  
File Role Description
  Accessible without login Plain text file glyphicons-halflings-regular.svg Data Auxiliary data

  Files folder image Files  /  tests  /  _reports  /  coverage  /  .js  
File Role Description
  Accessible without login Plain text file bootstrap.min.js Data Auxiliary data
  Accessible without login Plain text file d3.min.js Data Auxiliary data
  Accessible without login Plain text file file.js Data Auxiliary data
  Accessible without login Plain text file holder.min.js Data Auxiliary data
  Accessible without login Plain text file html5shiv.min.js Data Auxiliary data
  Accessible without login Plain text file jquery.min.js Data Auxiliary data
  Accessible without login Plain text file nv.d3.min.js Data Auxiliary data
  Accessible without login Plain text file respond.min.js Data Auxiliary data

  Files folder image Files  /  tests  /  _reports  /  logs  
File Role Description
  Accessible without login Plain text file clover.xml Data Auxiliary data

  Files folder image Files  /  tests  /  _reports  /  testdox  
File Role Description
  Accessible without login Plain text file executed.txt Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:84
This week:0
All time:9,207
This week:440Up