PHPackages                             temant/settings-manager - 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. [Database &amp; ORM](/categories/database)
4. /
5. temant/settings-manager

ActiveLibrary[Database &amp; ORM](/categories/database)

temant/settings-manager
=======================

A flexible, type-safe settings management library for PHP powered by Doctrine ORM.

v2.0.2(1mo ago)0631MITPHPPHP ^8.5CI failing

Since Sep 10Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Slvstar/Temant-Settings)[ Packagist](https://packagist.org/packages/temant/settings-manager)[ RSS](/packages/temant-settings-manager/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (8)Versions (12)Used By (1)

Temant Settings Manager
=======================

[](#temant-settings-manager)

[![Build Status](https://github.com/Slvstar/Temant-Settings/actions/workflows/ci.yml/badge.svg)](https://github.com/Slvstar/Temant-Settings/actions/workflows/ci.yml/badge.svg)[![Coverage Status](https://camo.githubusercontent.com/cc97af4369bcaa77545d9b4340074cefc8ba699401919e21ca479e0048033118/68747470733a2f2f636f6465636f762e696f2f67682f536c76737461722f54656d616e742d53657474696e67732f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://camo.githubusercontent.com/cc97af4369bcaa77545d9b4340074cefc8ba699401919e21ca479e0048033118/68747470733a2f2f636f6465636f762e696f2f67682f536c76737461722f54656d616e742d53657474696e67732f6272616e63682f6d61696e2f67726170682f62616467652e737667)[![License](https://camo.githubusercontent.com/b52fe6a8b3841c824d91bb84f52ec976782fcb917370143da088d4652327688f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f536c76737461722f54656d616e742d53657474696e6773)](https://camo.githubusercontent.com/b52fe6a8b3841c824d91bb84f52ec976782fcb917370143da088d4652327688f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f536c76737461722f54656d616e742d53657474696e6773)[![PHPStan](https://camo.githubusercontent.com/14995ff65edea59395c224e37e4fc66f91c1e601c1a58311e3c6f38c4fe37feb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c2532306d61782d627269676874677265656e)](https://camo.githubusercontent.com/14995ff65edea59395c224e37e4fc66f91c1e601c1a58311e3c6f38c4fe37feb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c2532306d61782d627269676874677265656e)[![PHP](https://camo.githubusercontent.com/4736d72fc425ff43bb7581aea9ef5e34b89bea3712983f43030df21e3c85a216/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e352532422d383839324246)](https://camo.githubusercontent.com/4736d72fc425ff43bb7581aea9ef5e34b89bea3712983f43030df21e3c85a216/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e352532422d383839324246)

A modern, type-safe settings management library for PHP applications powered by Doctrine ORM. Persist key-value settings to any database with automatic type detection, in-memory caching, group organisation, bulk operations, and import/export.

Features
--------

[](#features)

- **8 data types** — `string`, `integer`, `boolean`, `float`, `json`, `array`, `datetime`, and `auto` (auto-detect)
- **In-memory cache** — subsequent reads for the same key skip the database
- **Groups &amp; descriptions** — organise settings logically and document them inline
- **Bulk operations** — `setMany()`, `removeMany()`, `clear()`
- **Search &amp; filter** — substring search and group-based filtering
- **Import / Export** — JSON and array formats, round-trip safe
- **Fluent interface** — chain calls: `$manager->set(...)->set(...)->remove(...)`
- **Countable** — `count($manager)` returns the total number of settings
- **Doctrine ORM 3** — works with MySQL, PostgreSQL, and SQLite
- **PHPStan max level** — fully statically analysed
- **65 tests, 141 assertions** — comprehensive test suite

Installation
------------

[](#installation)

```
composer require temant/settings-manager
```

Requires **PHP 8.5+** and **Doctrine ORM 3**.

Quick Start
-----------

[](#quick-start)

```
use Temant\SettingsManager\SettingsManager;
use Temant\SettingsManager\Enum\SettingType;

// Create a manager with your Doctrine EntityManager
$manager = new SettingsManager($entityManager);

// Set values — type is auto-detected
$manager->set('site.name', 'Acme Corp');
$manager->set('cache.ttl', 3600);
$manager->set('debug', false);

// Get typed values back
$manager->getValue('site.name');   // 'Acme Corp' (string)
$manager->getValue('cache.ttl');   // 3600 (int)
$manager->getValue('debug');       // false (bool)

// Safe defaults for missing keys
$manager->getOrDefault('ui.theme', 'dark'); // 'dark'
```

Usage Guide
-----------

[](#usage-guide)

### Setting Values

[](#setting-values)

```
use Temant\SettingsManager\Enum\SettingType;

// Auto-detect type (default)
$manager->set('key', 'value');
$manager->set('count', 42);
$manager->set('enabled', true);
$manager->set('rate', 0.75);
$manager->set('config', '{"nested": true}');    // detected as JSON
$manager->set('tags', ['php', 'doctrine']);      // stored as ARRAY
$manager->set('launch', new DateTimeImmutable()); // stored as DATETIME

// Explicit type
$manager->set('port', '8080', SettingType::STRING); // force string, not int

// With metadata
$manager->set(
    name: 'smtp.host',
    value: 'mail.example.com',
    description: 'SMTP server hostname',
    group: 'email',
);

// Prevent accidental overwrites
$manager->set('api.key', 'secret', allowUpdate: false);
// throws SettingAlreadyExistsException if 'api.key' exists
```

### Retrieving Values

[](#retrieving-values)

```
// Full entity (with metadata, timestamps, etc.)
$entity = $manager->get('site.name');
$entity->getValue();       // typed value
$entity->getRawValue();    // raw string from DB
$entity->getType();        // SettingType::STRING
$entity->getDescription(); // ?string
$entity->getGroup();       // ?string
$entity->getCreatedAt();   // DateTimeImmutable
$entity->getUpdatedAt();   // ?DateTimeImmutable

// Shorthand — typed value directly
$manager->getValue('site.name');              // 'Acme Corp'

// With fallback
$manager->getOrDefault('missing.key', 'default'); // 'default'

// Existence check
$manager->exists('site.name'); // true
$manager->has('site.name');    // alias
```

### Updating Values

[](#updating-values)

```
use Temant\SettingsManager\Enum\UpdateType;

// Update value and auto-detect new type
$manager->update('cache.ttl', 7200);

// Update value but keep the original type (validates compatibility)
$manager->update('cache.ttl', 'not-an-int', UpdateType::KEEP_CURRENT);
// throws SettingTypeMismatchException
```

### Removing Values

[](#removing-values)

```
$manager->remove('old.setting');

// Remove multiple
$manager->removeMany(['key1', 'key2', 'key3']);

// Remove everything
$manager->clear();
```

### Bulk Operations

[](#bulk-operations)

```
$manager->setMany([
    'site.name'  => ['value' => 'Acme', 'type' => SettingType::STRING, 'group' => 'site'],
    'site.url'   => ['value' => 'https://acme.dev', 'group' => 'site'],
    'cache.ttl'  => ['value' => 3600, 'description' => 'Cache lifetime in seconds'],
    'debug.mode' => ['value' => false],
]);
```

### Search &amp; Filter

[](#search--filter)

```
// Substring search (case-insensitive)
$results = $manager->search('site');    // all settings with 'site' in the name

// Group filtering
$emailSettings = $manager->findByGroup('email');
```

### Counting

[](#counting)

```
$total = count($manager); // implements Countable
```

### Import &amp; Export

[](#import--export)

```
// Export all settings to array
$data = $manager->export();

// Export to JSON
$json = $manager->exportJson();

// Import from array
$manager->import($data);

// Import from JSON
$manager->importJson($json);

// Static utility classes also available
use Temant\SettingsManager\Utils\SettingsExporter;
use Temant\SettingsManager\Utils\SettingsImporter;

$json = SettingsExporter::toJson($manager);
SettingsImporter::fromJson($manager, $json);
```

### Default Settings

[](#default-settings)

Seed settings on first run — existing values are never overwritten:

```
$manager = new SettingsManager($entityManager, 'settings', [
    'site.name' => [
        'value' => 'My App',
        'type' => SettingType::STRING,
        'description' => 'Application name',
        'group' => 'site',
    ],
    'cache.ttl' => [
        'value' => 3600,
        // type auto-detected as INTEGER
    ],
    'debug' => [
        'value' => false,
    ],
]);
```

### Custom Table Name

[](#custom-table-name)

```
$manager = new SettingsManager($entityManager, 'app_config');
```

### Cache Management

[](#cache-management)

The manager caches entities in memory. If you modify the settings table externally:

```
$manager->clearCache();
```

Data Types
----------

[](#data-types)

SettingTypePHP TypeStorage FormatExample`STRING``string`As-is`'hello'``INTEGER``int`String cast`42``BOOLEAN``bool``'true'` / `'false'``true``FLOAT``float`String cast`3.14``JSON``array` (assoc)JSON string`'{"key":"val"}'``ARRAY``array`JSON encoded`['a', 'b']``DATETIME``DateTimeImmutable`ISO 8601`new DateTimeImmutable``AUTO`*(detected)**(varies)**(any of the above)*Exceptions
----------

[](#exceptions)

ExceptionWhen`SettingAlreadyExistsException``set()` with `allowUpdate: false` on existing key`SettingNotFoundException``update()` / `remove()` on missing key`SettingTypeMismatchException`Value incompatible with expected type`SettingsImportExportException`Import/export failure (bad JSON, missing keys)`SettingsTableInitializationException`Database table creation failureRunning Tests
-------------

[](#running-tests)

```
composer test
```

Static Analysis
---------------

[](#static-analysis)

```
composer phpstan
```

Run Both
--------

[](#run-both)

```
composer check-all
```

Contributing
------------

[](#contributing)

Contributions are welcome! Feel free to submit issues or pull requests.

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance90

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 98.2% 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 ~56 days

Recently: every ~70 days

Total

11

Last Release

48d ago

Major Versions

v1.2.4 → v2.0.02026-03-31

### Community

Maintainers

![](https://www.gravatar.com/avatar/3e96f21e803c229bcc4ec2e9b3f83535aa1723c9981a67d95513faee24e27d4f?d=identicon)[Slvstar](/maintainers/Slvstar)

---

Top Contributors

[![EmadAlmahdi](https://avatars.githubusercontent.com/u/135208774?v=4)](https://github.com/EmadAlmahdi "EmadAlmahdi (55 commits)")[![Slvstar](https://avatars.githubusercontent.com/u/77153715?v=4)](https://github.com/Slvstar "Slvstar (1 commits)")

---

Tags

phpconfigurationSettingsormdoctrinetyped-settings

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/temant-settings-manager/health.svg)

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

###  Alternatives

[laravel-doctrine/orm

An integration library for Laravel and Doctrine ORM

8425.3M87](/packages/laravel-doctrine-orm)[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58523.9M36](/packages/scienta-doctrine-json-functions)[fourlabs/qbjs-parser

Parse JSON coming from jQuery QueryBuilder, into database queries.

2535.3k2](/packages/fourlabs-qbjs-parser)[fourlabs/qbjs-parser-bundle

This bundle is a Symfony wrapper for fourlabs/qbjs-parser.

1514.7k1](/packages/fourlabs-qbjs-parser-bundle)

PHPackages © 2026

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