mbsoft31 / settings
This is my package settings
Fund package maintenance!
Mouadh Bekhouche
Requires
- php: ^8.2
- illuminate/contracts: ^10.0||^11.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
README
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.