承接 onaonbir/oo-settings 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

onaonbir/oo-settings

Composer 安装命令:

composer require onaonbir/oo-settings

包简介

Production-ready, high-performance settings management system for Laravel applications with caching, validation, and event support.

README 文档

README

OOSettings v2.0 is a high-performance, enterprise-grade settings management system for Laravel applications. Built from the ground up with production environments in mind, it provides comprehensive caching, validation, event handling, and advanced features for managing both global and model-specific settings.

✨ What's New in v2.0

🎯 Production-Ready Architecture

  • Complete rewrite with modern PHP 8.3+ features
  • Dependency injection and service container integration
  • Comprehensive error handling and logging
  • Type safety throughout the codebase

High-Performance Caching

  • Redis/Memcached support with intelligent cache tagging
  • Automatic cache invalidation strategies
  • Cache warming and statistics
  • 90%+ performance improvement over v1.x

🛡️ Enterprise Security & Validation

  • Input validation and sanitization
  • Support for encrypted sensitive settings
  • Rate limiting for setting operations
  • SQL injection and XSS protection

🎭 Event-Driven Architecture

  • Real-time events for setting changes
  • Audit trail capabilities
  • Cancellable operations
  • Custom event listeners

🔧 Advanced Features

  • Bulk operations for high-performance scenarios
  • Console commands for maintenance
  • Export/Import functionality
  • Statistics and monitoring
  • Multi-tenant support (optional)

🧱 Core Features

✅ Global & Model-Specific Settings

  • Global settings for application-wide configuration
  • Polymorphic model settings for user preferences, project configs, etc.
  • Dot notation support (user.preferences.theme)
  • Type-safe operations with automatic casting

✅ High-Performance Caching

// Automatic caching with Redis/Memcached
$value = oo_setting('app.name'); // Cached automatically
oo_setting_set('app.name', 'My App'); // Cache updated automatically

✅ Comprehensive Validation

// Built-in validation with custom rules
oo_setting_set('email.smtp.host', 'smtp.gmail.com'); // Validates automatically
oo_setting_set('max_users', 'invalid'); // Throws InvalidValueException

✅ Event System

// Listen to setting changes
Event::listen(SettingChanged::class, function ($event) {
    Log::info("Setting {$event->key} changed to {$event->value}");
});

✅ Bulk Operations

// High-performance bulk operations
oo_setting_many([
    'app.name' => 'My Application',
    'app.version' => '2.0.0',
    'mail.driver' => 'smtp'
]);

📦 Installation

1. Install via Composer

composer require onaonbir/oo-settings

2. Publish and Run Migrations

# Publish migration files
php artisan vendor:publish --tag=oo-settings-migrations

# Run migrations
php artisan migrate

3. Publish Configuration (Optional)

# Publish configuration file
php artisan vendor:publish --tag=oo-settings-config

🚀 Quick Start

Basic Usage

use OnaOnbir\OOSettings\Contracts\SettingsContract;

class AppController extends Controller
{
    public function __construct(private SettingsContract $settings) {}
    
    public function dashboard()
    {
        // Get settings with defaults
        $appName = $this->settings->get('app.name', 'Default App');
        $theme = $this->settings->get('ui.theme', 'light');
        
        // Set settings
        $this->settings->set('app.last_activity', now());
        
        return view('dashboard', compact('appName', 'theme'));
    }
}

Model-Specific Settings

use OnaOnbir\OOSettings\Traits\HasSettings;

class User extends Model
{
    use HasSettings;
}

// Usage
$user = User::find(1);

// Get user preferences
$theme = $user->getOOSetting('preferences.theme', 'light');
$notifications = $user->getOOSetting('notifications.email', true);

// Set user preferences
$user->setOOSetting('preferences.theme', 'dark');
$user->setOOSetting('preferences.language', 'en');

// Bulk operations
$user->setManyOOSettings([
    'privacy.profile_public' => false,
    'notifications.sms' => true,
    'preferences.timezone' => 'Europe/Istanbul'
]);

🎯 Helper Functions

Global Settings

// Get/Set global settings
$value = oo_setting('app.name', 'Default');
oo_setting_set('app.name', 'My App');
oo_setting_forget('app.name');

// Type casting
$maxUsers = oo_setting_as('limits.max_users', 100); // Returns integer
$isEnabled = oo_setting_as('feature.enabled', false); // Returns boolean

// Array operations
oo_setting_append('allowed_domains', 'example.com');
oo_setting_remove('allowed_domains', 'spam.com');

// Numeric operations
oo_setting_increment('stats.page_views');
oo_setting_decrement('limits.remaining_requests', 5);

// Boolean operations
$newValue = oo_setting_toggle('maintenance.enabled');

⚙️ Configuration

Cache Configuration

// config/oo-settings.php
return [
    'cache' => [
        'enabled' => true,
        'store' => 'redis', // null = default cache store
        'prefix' => 'oo_settings',
        'default_ttl' => 3600, // 1 hour
        'use_tags' => true, // Requires Redis/Memcached
    ],
];

Console Commands

# Clear settings cache
php artisan oo-settings:clear-cache

# Warm settings cache
php artisan oo-settings:warm-cache --pattern="app.*"

# Export settings
php artisan oo-settings:export settings-backup.json --include-meta

# Import settings
php artisan oo-settings:import settings-backup.json --merge

📊 Performance Benefits

Before OOSettings v2.0:

  • 150ms average response time for settings operations
  • Direct database queries on every request
  • No validation or type safety

After OOSettings v2.0:

  • 15ms average response time (90% improvement)
  • Intelligent caching with 95%+ hit ratio
  • Comprehensive validation and error handling

🔄 Migration from v1.x

OOSettings v2.0 maintains full backward compatibility:

// v1.x static methods still work
OOSettings::get('key', 'default');
OOSettings::set('key', 'value');

// v1.x trait methods still work
$user->getOOSetting('key');
$user->setOOSetting('key', 'value');

// v1.x helpers still work
oo_setting('key', 'default');
oo_setting_m($user, 'key');

Simply update your composer dependency:

composer update onaonbir/oo-settings

🧪 Testing

Run the test suite:

composer test

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

📄 License

This package is open-sourced software licensed under the MIT license.

🙏 Credits

Built by OnaOnbir.

License

MIT - See LICENSE for details.

onaonbir/oo-settings 适用场景与选型建议

onaonbir/oo-settings 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 87 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 08 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「cache」 「validation」 「events」 「laravel」 「Settings」 「dot-notation」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 onaonbir/oo-settings 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 onaonbir/oo-settings 我们能提供哪些服务?
定制开发 / 二次开发

基于 onaonbir/oo-settings 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-08