PHPackages                             onaonbir/oo-settings - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. onaonbir/oo-settings

ActiveLibrary[Caching](/categories/caching)

onaonbir/oo-settings
====================

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

2.1.0(3mo ago)090MITPHPPHP ^8.3CI passing

Since May 19Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/onaonbir/OO-Settings)[ Packagist](https://packagist.org/packages/onaonbir/oo-settings)[ Docs](https://onaonbir.com)[ GitHub Sponsors](https://github.com/sponsors/onaonbir)[ RSS](/packages/onaonbir-oo-settings/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (20)Versions (5)Used By (0)

🚀 OOSettings v2.0 — Production-Ready Settings Manager for Laravel
=================================================================

[](#-oosettings-v20--production-ready-settings-manager-for-laravel)

**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
--------------------

[](#-whats-new-in-v20)

🎯 **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 &amp; 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
---------------

[](#-core-features)

### ✅ Global &amp; Model-Specific Settings

[](#-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

[](#-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

[](#-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

[](#-event-system)

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

### ✅ Bulk Operations

[](#-bulk-operations)

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

---

📦 Installation
--------------

[](#-installation)

### 1. Install via Composer

[](#1-install-via-composer)

```
composer require onaonbir/oo-settings
```

### 2. Publish and Run Migrations

[](#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)

[](#3-publish-configuration-optional)

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

---

🚀 Quick Start
-------------

[](#-quick-start)

### Basic Usage

[](#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

[](#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
------------------

[](#-helper-functions)

### Global Settings

[](#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
----------------

[](#️-configuration)

### Cache 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

[](#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
----------------------

[](#-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
---------------------

[](#-migration-from-v1x)

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
---------

[](#-testing)

Run the test suite:

```
composer test
```

---

🤝 Contributing
--------------

[](#-contributing)

We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.

---

📄 License
---------

[](#-license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

---

🙏 Credits
---------

[](#-credits)

Built by [OnaOnbir](https://onaonbir.com).

---

License
-------

[](#license)

MIT - See [LICENSE](LICENSE) for details.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance82

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~105 days

Total

4

Last Release

94d ago

Major Versions

1.0.1 → 2.0.02025-08-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/2fb05958be043fd78fa4bd2047f2eb39e79d70aa581b88f78b5485115779add9?d=identicon)[onaonbir](/maintainers/onaonbir)

---

Top Contributors

[![bariskanberkay](https://avatars.githubusercontent.com/u/48731845?v=4)](https://github.com/bariskanberkay "bariskanberkay (9 commits)")

---

Tags

laravelvalidationSettingseventscacheKey valuedot notationpolymorphicmodel settings

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/onaonbir-oo-settings/health.svg)

```
[![Health](https://phpackages.com/badges/onaonbir-oo-settings/health.svg)](https://phpackages.com/packages/onaonbir-oo-settings)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.4M96](/packages/mongodb-laravel-mongodb)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M132](/packages/laravel-pulse)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k90.5k1](/packages/mike-bronner-laravel-model-caching)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
