danielemontecchi/laravel-scoped-settings
Composer 安装命令:
composer require danielemontecchi/laravel-scoped-settings
包简介
Manage global and model-scoped settings in Laravel with a clean API, artisan commands, and optional per-scope caching.
README 文档
README
Laravel Scoped Settings is a lightweight Laravel package that provides a simple and elegant way to manage global and model-scoped application settings.
- ⚡ Supports global settings and per-model scoped settings
- 🎯 API via Facade and
setting()helper - ✅ Includes artisan commands and full test suite
- 🚀 Optional per-scope caching built into
set()andget()
📦 Installation
You can install the package via Composer:
composer require danielemontecchi/laravel-scoped-settings
To customize default cache behavior, publish the config file:
php artisan vendor:publish --tag="laravel-scoped-settings-config"
To publish and run the migrations:
php artisan vendor:publish --tag="laravel-scoped-settings-migrations"
php artisan migrate
🛠 Usage
// Global settings setting()->set('site.name', 'My App'); $siteName = setting()->get('site.name'); // Set with optional caching (global or scoped) setting()->set('site.name', 'My App', 3600); // Cache for 1 hour // If TTL is omitted, uses default from config (or disables cache) setting()->set('site.name', 'My App'); // No cache if config is null // Check if a setting exists (ignores fallback) if (setting()->has('site.name')) { // the value is explicitly set } // Scoped settings (e.g. per user) setting()->for($user)->set('dashboard.layout', 'compact'); $layout = setting()->for($user)->get('dashboard.layout');
You can also retrieve all flat or grouped settings:
setting()->all(); // ['site.name' => 'My App'] setting()->for($user)->group('dashboard'); // ['layout' => 'compact']
Clear a specific key:
setting()->forget('site.name');
🛠 Artisan Commands
php artisan settings:list # Show all settings in CLI php artisan settings:clear # Clear all settings php artisan settings:export # Export settings to JSON php artisan settings:import # Import settings from JSON
🧪 Testing
./vendor/bin/pest
Coverage reports are generated via phpunit.xml config and uploaded to Codecov.
📚 Documentation
Full documentation available at:
👉 https://danielemontecchi.github.io/laravel-scoped-settings
Includes:
- Installation & Configuration
- Usage Examples
- Scoping Strategies
- Artisan Commands
- Advanced Tips
License
Laravel Scoped Settings is open-source software licensed under the MIT license. See the LICENSE.md file for full details.
Made with ❤️ by Daniele Montecchi
danielemontecchi/laravel-scoped-settings 适用场景与选型建议
danielemontecchi/laravel-scoped-settings 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 04 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「configuration」 「caching」 「laravel」 「Settings」 「model-settings」 「scoped」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 danielemontecchi/laravel-scoped-settings 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 danielemontecchi/laravel-scoped-settings 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 danielemontecchi/laravel-scoped-settings 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Configuration component
Query caching for Laravel 5
Simple PHP caching system that uses a tmp folder in a Linux environment.
Provides support for PSR-6 compatible cache for Yii1 application
Utils to load, parse and work with configuration on Mezzio projects
Trait to support creating complex nested class structures from JSON/YAML objects.
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-16