PHP Classes
elePHPant
Icontem

File: README.md

Recommend this page to a friend!
  Classes of Gavin Gordon Markowski  >  PHP Constant Groups  >  README.md  >  Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Constant Groups
Define groups of constant values from arrays
Author: By
Last change:
Date: 3 years ago
Size: 2,331 bytes
 

 

Contents

Class file image Download

ConstantGroups

Packagist Version Github Release Usage License

Description

A PHP class which provides quick as-needed access to pre- and user defined data via constants.

Dependencies

The following dependencies will be automatically installed, if not already, when installing via composer:

Usage

Installation

	composer require gavinggordon/constantgroups

Examples

Instantiation:

	include_once( __DIR__ . '/vendor/autoload.php' );
	
	$constantgroups = new \GGG\Config\ConstantGroups();

Setting:

Use as many or as few ConstantGroups as you want...

	$constantgroups->set( ['hexcolours', 'rgbcolours', 'rgbacolours'] );

Initializing:

	$constantgroups->init();

Utilization:

	echo HEX_ORANGE;
	// Result:  #FF8000

	echo RGB_ORANGE;
	// Result:  rgba( 255, 128, 0 )

	echo RGBA_ORANGE;
	// Result:  rgba( 255, 128, 0, 1.0 )

More Capabilities:

Create your own named ConstantGroups...

	use \GGG\Config\ConstantGroups as ConstantGroups;
	use \GGG\Config\ConstantGroupCreator as ConstantGroupCreator;
	
	$myconstantsgroup = [
		'my application name' => 'testapp',
		'application version' => '1.4.5',
		'apphomedir' => dirname( __DIR__ )
	];
	
	$constantgroupcreator = new ConstantGroupCreator( $myconstantsgroup );
	
	ConstantGroups::create( $constantgroupcreator, 'AppData' );
	
	$constantgroups = new ConstantGroups();
	
	$constantgroups->set( ['hexcolours', 'appdata'] );
	
	$constantgroups->init();
	
	echo MY_APPLICATION_NAME;
	// Result: testapp

Issues

If you have any issues at all, please post your findings in the issues page at https://github.com/gavinggordon/constantgroups/issues.

License

This package utilizes the MIT License.