gavinggordon/constantgroups

一个PHP类,它通过常量提供对预定义和用户定义数据的快速按需访问。

1.0.0 2017-02-01 14:12 UTC

This package is not auto-updated.

Last update: 2024-09-15 00:45:19 UTC


README

Packagist Version Github Release Usage License

描述

一个PHP类,它通过常量提供对预定义和用户定义数据的快速按需访问。

依赖关系

以下依赖项将在通过composer安装时自动安装(如果尚未安装):

使用方法

安装

	composer require gavinggordon/constantgroups

示例

实例化

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

设置

根据需要使用尽可能多的或尽可能少的ConstantGroups...

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

初始化

	$constantgroups->init();

使用

	echo HEX_ORANGE;
	// Result:  #FF8000
	echo RGB_ORANGE;
	// Result:  rgba( 255, 128, 0 )
	echo RGBA_ORANGE;
	// Result:  rgba( 255, 128, 0, 1.0 )

更多功能

创建自己的命名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

问题

如果您有任何问题,请将您的发现发布在https://github.com/gavinggordon/constantgroups/issues页面上的问题部分。

许可证

此软件包使用MIT许可证。