mbsoft31/settings 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

mbsoft31/settings

最新稳定版本:0.0.3

Composer 安装命令:

composer require mbsoft31/settings

包简介

This is my package settings

README 文档

README

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

Introduction

This package provides a simple and extensible way to manage application settings in various formats like JSON and YAML. It's designed to work seamlessly with Laravel and allows saving, loading, and managing configuration settings easily.

Features

  • Save and load application settings in JSON or YAML formats.
  • Easily extendable for additional formats.
  • Works out of the box with Laravel.
  • Configurable storage paths.

Installation

Step 1: Install via Composer

You can install the package using Composer:

composer require mbsoft31/settings

Step 2: Publish Configuration & Migrations

Publish the migrations and configuration files:

php artisan vendor:publish --tag="settings-migrations"
php artisan migrate

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

The configuration file (config/settings.php) will look like this:

return [
    // Define default paths or custom settings here
];

Optionally, you can publish views using:

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

Usage

Example: Save and Load JSON Settings

Here's a quick example of how to use the package to manage your application settings:

use MBsoft\Settings;

// Initialize settings
$settings = new Settings([
    'app.name' => 'My Application',
    'app.env' => 'local',
]);

// Save settings to a file
$settings->saveToFile(storage_path('settings.json'), \MBsoft\Settings\ConfigFormat::JSON);

// Load settings from a file
$loadedSettings = Settings::loadFromFile(storage_path('settings.json'), \MBsoft\Settings\ConfigFormat::JSON);

echo $loadedSettings->get('app.name'); // Outputs: "My Application"

Testing

Run the test suite using the following command:

composer test

To ensure the directory structure for file-based tests is correctly created during CI or local development, the package includes setup logic in the tests.

Advanced Usage

Supported Formats

Currently, the package supports:

  • JSON
  • YAML

You can extend the package to support additional formats by adding new serialization and deserialization methods.

Custom Configuration

You can modify the settings.php config file to define default file paths or application-specific settings.

Contributing

We welcome contributions! Please see the CONTRIBUTING guide for details.

Security Vulnerabilities

If you discover any security-related issues, please report them via the Security Policy.

Changelog

Refer to the CHANGELOG for recent updates.

Credits

License

This package is open-source software licensed under the MIT License.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固