samrap/gestalt

Gestalt 是一个简单、优雅的 PHP 包,用于管理框架的配置值。

v0.3.1 2016-10-06 18:15 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:09:33 UTC


README

StyleCI Build Status Latest Stable Version Total Downloads Latest Unstable Version

ge·stalt (n): 由许多部分组成,但某种方式上比其各部分的组合更多或不同的事物;广义上:某物的总体质量或特征。

Gestalt 是一个简单且优雅的 PHP 包,用于管理框架的配置值。它轻量级、灵活、与框架无关,并且除了 PHP 本身外没有其他依赖。

功能

  • 轻量级: Gestalt 设计得非常轻量级。没有依赖,没有冗余,只是围绕框架配置的对象封装。
  • 强大: 谁说轻量级就意味着无能为力?Gestalt 脚本小但功能强大。只需看看它的 自定义加载器观察者,你就能亲自见证。
  • 灵活: 开发者喜欢按自己的方式做事。Gestalt 允许你无缝集成到应用程序中。
  • 表达性语法:凭借其干净、类似集合的语法,代码艺术家会感到如鱼得水。混乱的开发者也会喜欢它!

示例

以下只是 Gestalt 提供的一些功能。有关安装、使用和功能的更多信息,请访问文档

基本用法 (了解更多)

$config = new Configuration([
    'app' => [
        'debug' => true,
        'version' => '1.0',
    ],
]);

// Get values using dot notation or ArrayAccess.
$config->get('app.debug');
$config['app'];

// Add values using dot notation or ArrayAccess.
$config->add('app.locale', 'en');
$config['mail'] = ['driver' => 'MailMonkey'];

自定义加载 (了解更多)

$config = Configuration::load(new JsonFileLoader);

$config->get('app.debug');

观察者 (了解更多)

$config = new Configuration($values);

$config->attach(new StatefulObserver);

// Notifies the StatefulObserver that the
// Configuration has been updated.
$config->set('app.debug', false);

感兴趣吗?查看文档,了解所有功能的实际应用!