PHPackages                             xgrz/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. xgrz/settings

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

xgrz/settings
=============

Easy handling for app settings in laravel

v2.0.11(3mo ago)0165MITPHPPHP ^8.1CI passing

Since Apr 9Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/xGrz/settings)[ Packagist](https://packagist.org/packages/xgrz/settings)[ RSS](/packages/xgrz-settings/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (12)Versions (15)Used By (0)

[![Version](https://camo.githubusercontent.com/e3a6613ca75526c733f7abed27da05ee87674729cceea7e659fc25e474ad0460/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f7867727a2f73657474696e67733f6c6162656c3d52656c6561736526636f6c6f723d73746f6e6526736f72743d73656d766572)](https://camo.githubusercontent.com/e3a6613ca75526c733f7abed27da05ee87674729cceea7e659fc25e474ad0460/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f7867727a2f73657474696e67733f6c6162656c3d52656c6561736526636f6c6f723d73746f6e6526736f72743d73656d766572)[![Tests](https://github.com/xGrz/settings/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/xGrz/settings/actions/workflows/tests.yml)[![Coverage](https://github.com/xGrz/settings/actions/workflows/coverage.yml/badge.svg)](https://github.com/xGrz/settings/actions/workflows/coverage.yml)[![L10](https://camo.githubusercontent.com/7918a38b82c1534258a04a1fc5a6ce203856035e97185bc7e8479b99c64539c1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d7631302e782d626c7565)](https://camo.githubusercontent.com/7918a38b82c1534258a04a1fc5a6ce203856035e97185bc7e8479b99c64539c1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d7631302e782d626c7565)[![L11](https://camo.githubusercontent.com/a198927a58cd373de6a8a701a7ac149c112386dbe14b1a2929b093977a43edc7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d7631312e782d626c7565)](https://camo.githubusercontent.com/a198927a58cd373de6a8a701a7ac149c112386dbe14b1a2929b093977a43edc7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d7631312e782d626c7565)[![L12](https://camo.githubusercontent.com/1e7eccbf00ec6136eea4f8c6acdf38f51d24cb547b3f2b17804c8dc355b044b1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d7631322e782d626c7565)](https://camo.githubusercontent.com/1e7eccbf00ec6136eea4f8c6acdf38f51d24cb547b3f2b17804c8dc355b044b1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d7631322e782d626c7565)[![L13](https://camo.githubusercontent.com/b9e388f860c3db95d088b1f17b3549c28afad477853b3b4ff4dad15dcc9eea18/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d7631332e782d626c7565)](https://camo.githubusercontent.com/b9e388f860c3db95d088b1f17b3549c28afad477853b3b4ff4dad15dcc9eea18/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d7631332e782d626c7565)

*Settings* Package for Laravel
==============================

[](#settings-package-for-laravel)

The Settings package for Laravel was created to facilitate easy management of global application settings in both development and production environments. Here are the main functions and features of the package:

Key Features
------------

[](#key-features)

1. **Application Settings Management** - the package allows storing and easy management of global application configuration
2. **File-Based Configuration** - definition of keys, types, and default values takes place in a configuration file
3. **Type Validation** - the package ensures proper data types are maintained (as defined in config)
4. **Performance** - utilization of caching mechanism (Redis or File recommended) to limit database queries
5. **Naming Standardization** - automatic formatting of keys according to the chosen convention (camel case, kebab case, or snake case)
6. **Nested keys** - `prefix.suffix` naming convention for all settings keys allows store structured data.

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

[](#installation)

1. Install the package from Packagist and publish the configuration:

    ```
    composer require xgrz/settings
    php artisan settings:publish-config
    php artisan settings:publish-migration

    ```
2. Edit the configuration file in your `config/app-settings` folder:

    - Customize your database table name
    - Set the cache key
    - Select [key generator convention](docs/key_generator.md)
    - Define the cache timeout
3. After customizing your configuration file, run the migration:

    ```
    php artisan migrate

    ```

    **Note:** Once the migration is completed, the `database_table` value in `config/app-settings` cannot be changed. Modifying it can break your application.
4. Define your settings in `settings/definitions.php` file (in main app directory) [details](docs/definitions.md).
5. Once your configuration is complete, initialize your settings with:

    ```
    php artisan settings:sync

    ```

Usage
-----

[](#usage)

You have two simple ways to retrieve your configuration values:

### Using the Facade

[](#using-the-facade)

```
try {
    XGrz\Settings\Facades\Settings::get($keyName);
} catch (XGrz\Settings\Exceptions\SettingKeyNotFoundException $e) {
    // Setting not found exception
}
```

### Using the Global Helper

[](#using-the-global-helper)

```
settings($keyName);
```

If the key is missing when using the global helper, an exception will be thrown as mentioned above. However, you can pass a second parameter to the `settings` helper as a default value. In this case, no exception will be thrown, and the default value will be returned.

```
settings(string $keyName, mixed $defaultValue);
```

### Retrieving an entire branch of settings

[](#retrieving-an-entire-branch-of-settings)

If you want to retrieve an entire branch of settings for a specific key, you must use a dot at the end. For example, to retrieve the "system" branch, use:

```
settings('system.');
```

From v2.0.6 you can also retrieve an entire main branch of settings using the `get` method:

```
settings();
```

If there are keys named `system.abc` and `system.bca`, an array will be returned:

```
array(
   'abc' => 'value1',
   'bca' => 'value2',
);

```

### Storing setting values

[](#storing-setting-values)

From v2.0.6 you can also store settings using the `set` method:

```
setSetting(string $key, mixed $value);
```

**Note:** If the key does not exist, exception will be thrown.

CI/CD deployments
-----------------

[](#cicd-deployments)

In your deployment script you should consider to add `php artisan settings:sync --silent` for safe settings sync, or `php artisan settings:sync --silent --force` if you want to force sync settings (test your app first!)

Warnings
--------

[](#warnings)

#### Avoid changing values at database level.

[](#avoid-changing-values-at-database-level)

Changes made that way will be not cached until you will flush app-cache or use:

```
    XGrz\Settings\Facades\Settings::invalidateCache();
    // or
    XGrz\Settings\Facades\Settings::refreshCache();
```

Preferred method for any changes is using model `XGrz\Settings\Models\Setting::class`.

#### Key generation

[](#key-generation)

Definition file is flattened with dot naming convention. Partial key names are formatted with defined generator type in your `config/app-settings.php` (*camel case* | kebab case | snake case).

If you decide to change key name generator type you can reformat your keys by using artisan console command:

```
   php artisan settings:format-keys

```

This command will walk through your config and apply new key naming type.

#### Changing setting type

[](#changing-setting-type)

You can safely change setting type in very limited way (for data integrity reasons). Allowed type changes:

- `SettingType::ON_OFF` to `SettingType::YES_NO`
- `SettingType::YES_NO` to `SettingType::ON_OFF`
- `SettingType::INTEGER` to `SettingType::FLOAT` (cannot change-back to integer)
- `SettingType::INTEGER` to `SettingType::DIGITS`
- `SettingType::STRING` to `SettingType::TEXT` (cannot change-back to string)
- `SettingType::DIGITS` to `SettingType::INTEGER` or `SettingType::TEXT`

You can delete key and create new one if you need to change setting\_type to other types.

Compatibility
-------------

[](#compatibility)

This package has been tested with:

- Laravel 10.x, 11.x, 12.x
- PHP 8.1-8.4
- MySQL, SQLite databases

Please note that for performance reasons, this package uses caching. It is recommended to use Redis or a file-based cache system instead of a database cache.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance80

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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

Recently: every ~14 days

Total

12

Last Release

107d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/33755434?v=4)[xGrz](/maintainers/xgrz)[@xGrz](https://github.com/xGrz)

---

Top Contributors

[![xGrz](https://avatars.githubusercontent.com/u/33755434?v=4)](https://github.com/xGrz "xGrz (167 commits)")

---

Tags

laravelSettings

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[laravel/octane

Supercharge your Laravel application's performance.

4.0k26.6M223](/packages/laravel-octane)[statamic/cms

The Statamic CMS Core Package

4.8k3.6M985](/packages/statamic-cms)[typicms/base

A modular multilingual CMS built with Laravel, enabling developers to manage structured content like pages, news, events, and more.

1.6k20.4k](/packages/typicms-base)[code16/sharp

Laravel Content Management Framework

79164.7k8](/packages/code16-sharp)[firefly-iii/data-importer

Firefly III Data Import Tool.

8045.8k](/packages/firefly-iii-data-importer)[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17878.9k](/packages/markwalet-nova-modal-response)

PHPackages © 2026

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