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

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

daycry/settings
===============

Settings library for CodeIgniter 4

v1.0.8(1y ago)34.3k2MITPHPPHP ^7.3 || ^8.0

Since Sep 1Pushed 1y ago1 watchersCompare

[ Source](https://github.com/daycry/settings)[ Packagist](https://packagist.org/packages/daycry/settings)[ Docs](https://github.com/daycry/settings)[ RSS](/packages/daycry-settings/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (3)Versions (10)Used By (2)

[![Donate](https://camo.githubusercontent.com/604e3db9c8751116b3f765aad0353ec7ded655bbe8aaacbc38d8c4a6b784b3ed/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d50617950616c2d677265656e2e737667)](https://www.paypal.com/donate?business=SYC5XDT23UZ5G&no_recurring=0&item_name=Thank+you%21&currency_code=EUR)

CodeIgniter 4 Settings
======================

[](#codeigniter-4-settings)

Provides database storage and retrieval of application settings, with a fallback to the config classes.

[![Build Status](https://github.com/daycry/settings/workflows/PHP%20Tests/badge.svg)](https://github.com/daycry/settings/actions?query=workflow%3A%22PHP+Tests%22)[![Downloads](https://camo.githubusercontent.com/484f318201c60dcba5f44c38a2193569138c45f8036a3b090336cb61054ad348/68747470733a2f2f706f7365722e707567782e6f72672f6461796372792f73657474696e67732f646f776e6c6f616473)](https://packagist.org/packages/daycry/settings)[![GitHub release (latest by date)](https://camo.githubusercontent.com/65b71a2934e9d6f5beff21c853559edf750cac5bddc3f0ddfedfc4a973832336/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6461796372792f73657474696e6773)](https://packagist.org/packages/daycry/settings)[![GitHub stars](https://camo.githubusercontent.com/6e0cda466d5c5e10690972f82ee509a25fe42233414d022dd67be7a4dec51f44/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6461796372792f73657474696e6773)](https://packagist.org/packages/daycry/settings)[![GitHub license](https://camo.githubusercontent.com/fc717dbcd6b51fd60ed93efd415b7901f54af93a8476f7256f40a99b2b6cbc9e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6461796372792f73657474696e6773)](https://github.com/daycry/settings/blob/master/LICENSE)

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

[](#quick-start)

1. Install with Composer: `> composer require daycry/settings`
2. Create a new migration and copy the provided class from below into it.

`Settings` provides a simple interface that you can use in place of calling `config()` to allow you to read and store config values in the database. If the value has not been updated and saved in the database then the original value from the config file will be used.

This allows you to save your application's default state as values in config files, all stored in version control, and still allows your users to override those settings once the site is live.

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

[](#installation)

Install easily via Composer to take advantage of CodeIgniter 4's autoloading capabilities and always be up-to-date:

- `> composer require daycry/settings`

Manual installation
-------------------

[](#manual-installation)

Download this repo and then enable it by editing **app/Config/Autoload.php** and adding the **Daycry\\Settings**namespace to the **$psr4** array. For example, if you copied it into **app/ThirdParty**:

```
$psr4 = [
    'Config'      => APPPATH . 'Config',
    APP_NAMESPACE => APPPATH,
    'App'         => APPPATH,
    'Daycry\Settings' => APPPATH .'ThirdParty/settings/src',
];
```

Setup
-----

[](#setup)

Run command:

```
> php spark settings:publish

```

This command will copy a config file to your app namespace. Then you can adjust it to your needs. By default file will be present in `app/Config/Settings.php`.

In order to store the settings in the database, you can run the provided migration:

```
> php spark migrate --all

```

This will also migrate all other packages. If you don't want to do that you can copy the file from `vendor/daycry/settings/src/Database/Migrations/2021-09-01-000001_CreateSettingsTable.php`into `app/Database/Migrations`, and migrate without the `--all` flag.

dot Notation
------------

[](#dot-notation)

This library uses what we call "dot notation" to specify the class name and the property name to use. These are joined by a dot, hence the name.

If you have a class named `App`, and the property you are wanting to use is `siteName`, then the key would be `App.siteName`.

Usage
-----

[](#usage)

To retrieve a config value use the `settings` service.

```
// The same as config('App')->siteName;
$siteName = service('settings')->get('App.siteName');
```

In this case we used the short class name, `App`, which the `config()` method automatically locates within the `app/Config` directory. If it was from a module, it would be found there. Either way, the fully qualified name is automatically detected by the Settings class to keep values separated from config files that may share the same name but different namespaces. If no config file match is found, the short name will be used, so it can be used to store settings without config files.

To save a value, call the `set()` method on the settings class, providing the class name, the key, and the value. Note that boolean `true`/`false` will be converted to strings `:true` and `:false` when stored in the database, but will be converted back into a boolean when retrieved. Arrays and objects are serialized when saved, and unserialized when retrieved.

```
service('settings')->set('App.siteName', 'My Great Site');
```

You can delete a value from the persistent storage with the `forget()` method. Since it is removed from the storage, it effectively resets itself back to the default value in config file, if any.

```
service('settings')->forget('App.siteName')
```

### Using the Helper

[](#using-the-helper)

The helper provides a shortcut to the using the service. It must first be loaded using the `helper()` method or telling your BaseController to always load it.

```
helper('setting');

$name = setting('App.siteName');
// Store a value
setting('App.siteName', 'My Great Site');

// Using the service through the helper
$name = setting()->get('App.siteName');
setting()->set('App.siteName', 'My Great Site');

// Forgetting a value
setting()->forget('App.siteName');
```

Known Limitations
-----------------

[](#known-limitations)

The following are known limitations of the library:

1. Using the `setting()` helper method does not support setting a `null` value on a property. For most cases, you are better off forgetting the value or setting it to an empty string. If you need to, you can set it by grabbing the service and using the `set()` method:

```
service('settings')->set('App.siteName', null);
setting()->set('App.siteName', null);
```

2. You can currently only store a single setting at a time. While the `DatabaseHandler` uses a local cache to keep performance as high as possible for reads, writes must be done one at a time.
3. You can only access the first level within a property directly. In most config classes this is a non-issue, since the properties are simple values. Some config files, like the `database` file, contain properties that are arrays.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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 ~129 days

Recently: every ~217 days

Total

9

Last Release

682d ago

### Community

Maintainers

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

---

Top Contributors

[![daycry](https://avatars.githubusercontent.com/u/7590335?v=4)](https://github.com/daycry "daycry (23 commits)")

---

Tags

Settingsconfigdatabasecodeignitercodeigniter4

###  Code Quality

Static AnalysisRector

### Embed Badge

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

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

###  Alternatives

[arcanedev/laravel-settings

This package allows you to persists configs/settings for Laravel projects.

74131.4k6](/packages/arcanedev-laravel-settings)[tatter/relations

Entity relationships for CodeIgniter 4

9022.3k1](/packages/tatter-relations)[tatter/schemas

Database schema management, for CodeIgniter 4

2328.5k1](/packages/tatter-schemas)[illuminatech/config

Provides support for Laravel application runtime configuration managed in persistent storage

14921.0k1](/packages/illuminatech-config)[aplus/config

Aplus Framework Config Library

161.6M3](/packages/aplus-config)

PHPackages © 2026

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