定制 centrex/laravel-settings 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

centrex/laravel-settings

最新稳定版本:v1.3.2

Composer 安装命令:

composer require centrex/laravel-settings

包简介

Manage settings in laravel

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Settings for Laravel allows you to store your application settings in the database. It works alongside of the built-in configuration system that Laravel offers. With this package, you can store application specific settings.

Contents

Installation

You can install the package via composer:

composer require centrex/laravel-settings

You can publish the config file with:

php artisan vendor:publish --tag="settings-config"

You can publish and run the migrations with:

php artisan migrate

Usage

To get and retrieve stored settings, you can do it easily with the Settings Facade or by using the settings() helper function:

// Set a setting
Settings::set('foo', 'bar');
settings()->set('foo', 'bar');
settings(['foo' => 'bar']);

// Get a setting
Settings::get('foo'); // 'bar'
settings()->get('foo');
settings('foo');

// Check existence
if (settings()->has('app.debug')) {
    // ...
}

// Remove a setting
settings()->forget('old.setting');

// Refresh cache
settings()->refreshCache();
// Check if setting exists (cached)
Setting::exists('app.timezone');

// Get autoloaded settings
Setting::autoload()->get();

// Get settings in a group
Setting::group('email')->get();

// Find settings with matching keys
Setting::keyLike('app.')->get();

// Remove a setting
Setting::remove('old.setting');

Helpers

// Get a setting with default value
$timezone = settings('app.timezone', 'UTC');

// Get using dedicated function
$debug = get_setting('app.debug', false);

// Set a setting
set_setting('app.maintenance_mode', true);

// Check existence
if (setting_exists('app.feature_flag')) {
    // ...
}

// Remove a setting
remove_setting('old.setting');

// Access Settings instance directly
settings()->refreshCache();

Testing

🧹 Keep a modern codebase with Pint:

composer lint

✅ Run refactors using Rector

composer refacto

⚗️ Run static analysis using PHPStan:

composer test:types

✅ Run unit tests using PEST

composer test:unit

🚀 Run the entire test suite:

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 2.53k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-16