edwinhoksberg / settings
1.0.1
2016-07-11 20:33 UTC
Requires
- php: >= 7.0.0
Requires (Dev)
- phpunit/phpunit: ^5.4
- satooshi/php-coveralls: ^1.0
This package is auto-updated.
Last update: 2024-09-20 10:07:21 UTC
README
这是一个使用所谓的点表示法管理应用程序设置的非常简单的库。主要用于我的个人项目。
安装
使用composer
在您的终端中执行此命令
composer require edwinhoksberg/settings
或将此行添加到您的composer.json require
部分
"edwinhoksberg/settings": "~1.0"
然后运行 composer update
不使用composer
只需在您的项目中引入Settings.php
文件
require 'src/Settings.php';
如何使用
// settings.php should just be a return statement with an array. // See tests/fixtures/settings.php for an example. Settings::loadFromFile('settings.php'); // Load from an array Settings::loadFromArray([ 'settings' => ... ]); // Get a setting value using dot notation Settings::get('database.username', 'defaultuser'); // Retrieve the entire settings array Settings::getAll(); // You can also set/replace settings with dot notation Settings::set('database.password', 'toor'); // Check if a setting value exists Settings::has('database.password'); // Returns true or false // Remove all settings Settings::clear();
测试
测试文件位于tests
目录中,可以使用phpunit运行
phpunit -c phpunit.dist.xml