2017 © Pedro Peláez
 

library configfile

Get constants from a configuration file written in PHP

image

activecollab/configfile

Get constants from a configuration file written in PHP

  • Monday, September 7, 2015
  • by ilijastuden
  • Repository
  • 3 Watchers
  • 1 Stars
  • 10,336 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 10 % Grown

The README.md

ConfigFile Library

Build Status, (*1)

Simple utility for getting constants from configuration files written in PHP., (*2)

Installation

To install it, use Composer:, (*3)

{
    "require": {
        "activecollab/configfile": "~1.0"
    }
}

Usage

If we have a config.example.php file that looks like this:, (*4)

<?php

const ONE = 1;
define ('TWO', 2);
defined ('THREE') or define('THREE', 3);

const THIS_IS_TRUE = true;
define ("THIS_IS_FALSE", false);

const SINGLE_QUOTED_STRING = 'single';
const DOUBLE_QUOTED_STRING = 'double';

define('FLOAT', 2.25);

// Declaration in comment should be ignored  define('IGNORE_ME', true);
// Same thing about const THIS_SHOULD_BE_IGNORED = true;

and we parse it like this:, (*5)

<?php

use ActiveCollab\ConfigFile\ConfigFile;

$config_file = new ConfigFile('config.example.php');
var_dump($config_file->getOptions());

we'll get:, (*6)

array(8) {
  ["ONE"]=>
  int(1)
  ["TWO"]=>
  int(2)
  ["THREE"]=>
  int(3)
  ["THIS_IS_TRUE"]=>
  bool(true)
  ["THIS_IS_FALSE"]=>
  bool(false)
  ["SINGLE_QUOTED_STRING"]=>
  string(6) "single"
  ["DOUBLE_QUOTED_STRING"]=>
  string(6) "double"
  ["FLOAT"]=>
  float(2.25)
}

To Do

This library has been created in a bit of a rush, so there are still some things to do:, (*7)

  1. const should be parsed using tokenizer
  2. Follow included files using include and require [?]
  3. Library should be able to modify and write config files [?]

The Versions

07/09 2015

dev-master

9999999-dev

Get constants from a configuration file written in PHP

  Sources   Download

MIT

The Requires

  • ext-ctype *
  • ext-mbstring *

 

The Development Requires

configuration activecollab const define

07/09 2015

1.0.1

1.0.1.0

Get constants from a configuration file written in PHP

  Sources   Download

MIT

The Requires

  • ext-ctype *
  • ext-mbstring *

 

The Development Requires

configuration activecollab const define

09/08 2015

1.0.0

1.0.0.0

Get constants from a configuration file written in PHP

  Sources   Download

MIT

The Requires

  • ext-ctype *
  • ext-mbstring *

 

The Development Requires

configuration activecollab const define