rayhan2001/laravel-settings-manager
Composer 安装命令:
composer require rayhan2001/laravel-settings-manager
包简介
A simple and reusable Laravel package for managing application settings (general, email, social, payment, etc).
README 文档
README
A simple and reusable Laravel package for managing application settings (general, email, social, payment, etc).
Features
- Easy to use settings management system
- Built-in UI for managing settings (optional)
- Caching for improved performance
- Configurable form sections and fields
- Support for various field types (text, email, url, select, password, etc)
- Ready-to-use migrations, config, and views
Installation
Step 1: Add Package to Autoloader
Add the package to your main composer.json file's autoload section:
"autoload": { "psr-4": { "App\\": "app/", "Database\\Factories\\": "database/factories/", "Database\\Seeders\\": "database/seeders/", "Rayhan\\Settings\\": "laravel-settings-manager/src/" } }
Then run:
composer dump-autoload
Step 2: Register Service Provider
Add the service provider to your bootstrap/providers.php file:
return [ App\Providers\AppServiceProvider::class, Rayhan\Settings\SettingsServiceProvider::class, // Add this line ];
Step 3: Publish Assets
Publish the package assets using one of the following commands:
Publish All Assets
php artisan vendor:publish --provider="Rayhan\Settings\SettingsServiceProvider"
Publish Only Config
php artisan vendor:publish --provider="Rayhan\Settings\SettingsServiceProvider" --tag=config
Publish Only Migrations
php artisan vendor:publish --provider="Rayhan\Settings\SettingsServiceProvider" --tag=migrations
Publish Only Views
php artisan vendor:publish --provider="Rayhan\Settings\SettingsServiceProvider" --tag=views
Step 4: Run Migrations
Run the migrations to create the settings table:
php artisan migrate
Configuration
The configuration file is published to config/settings.php. You can customize the following options:
UI Settings
ui.enabled: Enable/disable the built-in UI (default: true)ui.middleware: Middleware for UI routes (default: ['web', 'auth'])ui.prefix: Route prefix for UI (default: 'admin/settings')ui.route_name_prefix: Route name prefix (default: 'settings.')
Cache Settings
cache.enabled: Enable/disable caching (default: true)cache.key: Cache key (default: 'rayhan.settings.all')cache.ttl: Cache time-to-live in seconds (default: 3600)
Form Sections
The package comes with pre-configured form sections:
- General settings (site name, tagline, URL)
- Email settings (SMTP configuration)
- Social media links
- Payment gateway settings (Stripe, PayPal, SSLCommerz)
Usage
Using the Settings Facade
// Get a setting value $value = Settings::get('site_name'); // Set a setting value Settings::set('site_name', 'My Awesome Site'); // Get all settings $allSettings = Settings::all(); // Check if a setting exists if (Settings::has('site_name')) { // Do something }
Using the Settings Helper
// Get a setting value $value = settings('site_name'); // Set a setting value settings(['site_name' => 'My Awesome Site']); // Get all settings $allSettings = settings();
Using the Settings Service
use Rayhan\Settings\Services\SettingsManager; class YourController extends Controller { public function index(SettingsManager $settings) { $siteName = $settings->get('site_name'); // ... } }
Available Field Types
The package supports various field types for the built-in UI:
text: Text inputemail: Email inputurl: URL inputnumber: Number inputselect: Dropdown selectpassword: Password inputtextarea: Textarea
Customization
Adding New Sections
You can add new sections by modifying the sections array in config/settings.php:
'sections' => [ 'general' => [ // ... ], 'custom' => [ 'title' => 'Custom Section', 'icon' => 'bi-star', 'fields' => [ [ 'type' => 'text', 'label' => 'Custom Field', 'key' => 'custom_field', 'placeholder' => 'Enter custom value', 'rules' => 'nullable|string|max:255', ], ], ], ],
Modifying UI Routes
You can disable the built-in UI by setting ui.enabled to false in the config file, or customize the middleware and route prefix as needed.
Requirements
- PHP 8.1 or higher
- Laravel 10.0 or higher
License
The MIT License (MIT). Please see License File for more information.
rayhan2001/laravel-settings-manager 适用场景与选型建议
rayhan2001/laravel-settings-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 08 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 rayhan2001/laravel-settings-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rayhan2001/laravel-settings-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-24