2017 © Pedro Peláez
 

library dotconst

The Neutrino dotconst package.

image

neutrino/dotconst

The Neutrino dotconst package.

  • Friday, February 2, 2018
  • by Ark4ne
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

Loads constants variables from .const.ini, .const.[APP_ENV].ini files., (*1)

How Use

Make sure the .const.ini, .const.*.ini, file is added to your .gitignore so it is not checked-in the code., (*2)

Add this to your .gitignore :, (*3)

.const.ini
.const.*.ini

Create your .const.ini and put any variables in !, (*4)

Dotconst work with .ini file., (*5)

Every sections will be flatten. Each variable will be prefixed with the section name., (*6)

Every variable will be UPPERIZED. e.g., (*7)

[database]
user = db_user

Will become, (*8)

DATABASE_USER === 'db_user'

Special key

base_path = @php/dir
app_env = @php/env:APP_ENV
php_v = @php/const:PHP_VERSION_ID

Will become :, (*9)

BASE_PATH === {base path of .const.ini file}
APP_ENV === getenv('APP_ENV')
PHP_V === PHP_VERSION_ID

And compile :, (*10)

define('BASE_PATH', '{base path of .const.ini file}');
define('APP_ENV', getenv('APP_ENV'));
define('PHP_V', PHP_VERSION_ID);

Loading

It's really simple, just add this to your bootstrap :, (*11)

\Neutrino\Dotconst::load('/ini_path' [, '/compile_path']);

Environment Overloading

The first file called is ".const.ini". If the variable "APP_ENV" is defined in this file, dotconst will look for the file ".const. {APP_ENV} .ini", and override the base values. Useful when working on multiple environments., (*12)

; .const.ini
[app]
env = production

[database]
host = localhost
; .const.production.ini
[database]
host = 10.0.0.0

Will become, (*13)

DATABASE_HOST === '10.0.0.0'

Compilation

For the best performance, you can compile the variables loaded into a php file, by calling :, (*14)

\Neutrino\Dotconst\Compile::compile('/ini_path', '/compile_path');

Will generate for this ini file :, (*15)

; .const.ini
[database]
user = db_user
define('DATABASE_USER', 'db_user');

Extensions

I can easily extends Dotconst :, (*16)

class MyExtention extends \Neutrino\Dotconst\Extensions\Extension{

    protected $identifier = "php/my";

    public function parse($value, $path) {
        return 'my';
    }

    public function compile($value, $path){
        return "'my'";
    }
}

\Neutrino\Dotconst::addExtension(MyExtention::class);

In your .const.ini file :, (*17)

[foo]
bar = @php/my

Will be parse :, (*18)

FOO_BAR === 'my'

And compile :, (*19)

define('FOO_BAR', 'my');

The Versions

02/02 2018

dev-master

9999999-dev https://phalcon-nucleon.github.io

The Neutrino dotconst package.

  Sources   Download

MIT

The Requires

  • php >=5.6.1

 

The Development Requires

by Ark4ne (Guillaume Allegret)

environment const nucleon neutrino dotconst

02/02 2018

v1.0.0

1.0.0.0 https://phalcon-nucleon.github.io

The Neutrino dotconst package.

  Sources   Download

MIT

The Requires

  • php >=5.6.1

 

The Development Requires

by Ark4ne (Guillaume Allegret)

environment const nucleon neutrino dotconst

02/02 2018

1.0.x-dev

1.0.9999999.9999999-dev https://phalcon-nucleon.github.io

The Neutrino dotconst package.

  Sources   Download

MIT

The Requires

  • php >=5.6.1

 

The Development Requires

by Ark4ne (Guillaume Allegret)

environment const nucleon neutrino dotconst

25/05 2017

0.2.0

0.2.0.0 https://phalcon-nucleon.github.io

The Neutrino dotconst package.

  Sources   Download

MIT

The Requires

  • php >=5.6.1

 

The Development Requires

by Ark4ne (Guillaume Allegret)

environment const nucleon neutrino dotconst

25/05 2017

0.1.x-dev

0.1.9999999.9999999-dev https://phalcon-nucleon.github.io

The Neutrino dotconst package.

  Sources   Download

MIT

The Requires

  • php >=5.6.1

 

The Development Requires

by Ark4ne (Guillaume Allegret)

environment const nucleon neutrino dotconst

25/05 2017

0.1.1

0.1.1.0 https://phalcon-nucleon.github.io

The Neutrino dotconst package.

  Sources   Download

MIT

The Requires

  • php >=5.6.1

 

The Development Requires

by Ark4ne (Guillaume Allegret)

environment const nucleon neutrino dotconst

24/05 2017

0.1.0

0.1.0.0 https://phalcon-nucleon.github.io

The Neutrino dotconst package.

  Sources   Download

MIT

The Requires

  • php >=5.6.1

 

The Development Requires

by Ark4ne (Guillaume Allegret)

environment const nucleon neutrino dotconst