PHPackages                             hackeresq/laravel-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. [Security](/categories/security)
4. /
5. hackeresq/laravel-settings

ActiveLibrary[Security](/categories/security)

hackeresq/laravel-settings
==========================

Super simple key/value settings for Laravel 8+

v3.2.1(3y ago)312.1k↓50%9MITPHPPHP &gt;=8.0CI failing

Since Sep 28Pushed 3y ago1 watchersCompare

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

READMEChangelog (10)Dependencies (4)Versions (20)Used By (0)

Settings
========

[](#settings)

[![Latest Version on Packagist](https://camo.githubusercontent.com/27868dc359e8e26509161fb510877d0eafff2e6affa844dc68109cd84cc7da65/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6861636b65724553512f6c61726176656c2d73657474696e67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hackerESQ/laravel-settings)[![Total Downloads](https://camo.githubusercontent.com/bb6e28f2539d93cbc9468cc038986183fe0da1c6b403ff3d9d465245d028755b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6861636b65724553512f6c61726176656c2d73657474696e67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hackerESQ/laravel-settings)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

Super simple key/value settings for Laravel that natively supports [encryption](#encryption) and [multi-tenancy](#multi-tenancy).

- [Installation](#installation)
- [Usage](#usage)
    - [Set new setting](#set-new-setting)
    - [Get all settings](#get-all-settings)
    - [Get single setting](#get-single-setting)
    - [Get certain setting (via array)](#get-certain-settings)
    - [Check if a setting is set](#check-if-a-setting-is-set)
- [Encryption](#encryption)
- [Multi-tenancy](#multi-tenancy)
- [Casting](#casting)
- [Disable cache](#disable-cache)
- [Hidden settings](#hidden-settings)
- [Customize table name](#customize-table-name)

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

[](#installation)

This package can be used in Laravel 8.0+.

You can install the package via composer:

```
composer require hackeresq/laravel-settings
```

Since Laravel 5.5+, service providers and aliases will automatically get registered and you can skip this step. To use this package with older versions, please use release &lt; 2.0.

You can publish [the migration](https://github.com/hackerESQ/settings/blob/master/database/migrations/create_settings_table.php) and [config](https://github.com/hackerESQ/settings/blob/master/config/settings.php) files, then migrate the new settings table all in one go, using:

```
php artisan vendor:publish --provider="HackerESQ\Settings\SettingsServiceProvider" --tag=migrations && php artisan vendor:publish --provider="HackerESQ\Settings\SettingsServiceProvider" --tag=config && php artisan migrate
```

**Success!** laravel-settings is now installed!

Usage
-----

[](#usage)

Settings can be accessed using the easy-to-remember Facade, `Settings`.

### Set new setting

[](#set-new-setting)

You can set new settings using the "set" method, which accepts an associative array of one or more key/value pairs. **For security reasons,** this will first check to see if such a setting key is "fillable," which is a configuration option in the [config/settings.php](https://github.com/hackerESQ/settings/blob/master/config/settings.php) file.

If such a key exists in the config, it will update the key to the new value passed. If the key does not exist in the fillable config, *it will disregard the change.* So, if this is a fresh install, do not expect the following to work:

```
Settings::set(['firm_name'=>'new']);
```

It will not set the new setting until you have either set the fillable fields in the config, or you have opted to force the setting. If you wish to force set a new setting, you should use the `force()` method before calling the `set()` method:

```
Settings::force()->set(['firm_name'=>'new']);
```

As of version 3.0.4, the global override for forcing settings has been removed from the config file for this package. Instead, you can use a wildcard for the fillable property, like this:

```
'fillable' => ['*']
```

This is more in line with standard Laravel syntax (e.g. for models).

### Get all settings

[](#get-all-settings)

If no parameters are passed to the "get" method, it will return an array of all settings:

```
Settings::get();
```

You can optionally hide specific settings using the `hidden` config as described [below](#hidden-settings).

### Get single setting

[](#get-single-setting)

You can return a single setting by passing a single setting key:

```
Settings::get('firm_name');
```

### Get certain settings

[](#get-certain-settings)

You can also return a list of specified settings by passing an array of setting keys:

```
Settings::get(['firm_name','contact_types']);
```

### Check if a setting is set

[](#check-if-a-setting-is-set)

Sometimes you can't know if a setting has been set or not (i.e. boolean settings that will return false if the setting does not exist, but also if the setting has been set to false).

```
Settings::has(['dark_theme']);
```

Encryption
----------

[](#encryption)

You can define keys that should be encrypted automatically within the [config/settings.php](https://github.com/hackerESQ/settings/blob/master/config/settings.php) file. To do so, add the keys as such:

```
'encrypt' => [
        'twitter_client_id',
        'twitter_client_secret',
    ],
```

Multi-tenancy
-------------

[](#multi-tenancy)

This package can be used in a multi-tenant environment. The [set](#set-new-setting), [get](#get-all-settings), and [has](#check-if-a-setting-is-set) methods all read an internal 'tenant' attribute that can be set with the `tenant()` method. You can set the 'tenant' attribute by calling the `tenant()` method first, like this:

```
Settings::tenant('tenant_name')->set(['firm_name'=>'foo bar']);

// returns true (i.e. successfully set `firm name`)
```

```
Settings::tenant('tenant_name')->get('firm_name');

// returns 'foo bar'
```

```
Settings::tenant('tenant_name')->has('firm_name');

// returns true
```

The 'tenant' attribute passed can be any alphanumeric string. The 'tenant' attribute can also be left blank to have, for example, settings saved to a so-called "central" tenant. Note: the 'tenant' attribute is not strictly typed, and will be passed to the database query as a string.

Casting
-------

[](#casting)

You can cast settings to native PHP types using the `cast` option in the settings.php config. Here's an example of an array being cast to JSON and back to a native PHP array:

```
// settings.php

'cast' => [
  'array_of_values' => 'json'
]
```

Which allows you to do the following:

```
Settings::set(['array_of_values' => ['one', 'two', 'three']]);

return Settings::get('array_of_values');

// returns a PHP array: ['one', 'two', 'three']
```

Disable cache
-------------

[](#disable-cache)

Depending on your use case, you may like to disable the cache (enabled by default). Disable the cache by modifying the [config/settings.php](https://github.com/hackerESQ/settings/blob/master/config/settings.php) file as such:

```
'cache' => false
```

Hidden settings
---------------

[](#hidden-settings)

You may wish to hide specific settings (like API keys or other sensitive user data) from inadvertent disclosure. You can set these settings in the [config/settings.php](https://github.com/hackerESQ/settings/blob/master/config/settings.php) file. To do so, add the keys as such:

```
'hidden' => [
        'twitter_client_secret',
        'super_secret_password',
    ],
```

Once these are set, they must be specifically requested using the `get()` method. In other words, this acts like the `$hidden` attribute on Laravel Eloquent models.

In addition to hiding specific settings, you can opt to hide ALL the settings (unless specifically requested, of course). To do this, you can use a wildcard:

```
'hidden' => ['*'],
```

Customize table name
--------------------

[](#customize-table-name)

For some cases, it may be necessary to customize the name of the table where settings are stored. By default, the migrations that come with this package create a 'settings' table. If, for some reason, it becomes necessary to change the default table, you can set the 'table' option in the [config/settings.php](https://github.com/hackerESQ/settings/blob/master/config/settings.php) file, like this:

```
'table' => 'user_options_table',
```

This configuration option is not included in the base config file as this is an edge case that is not commonly encountered; but nonetheless a nice convenience to have when it does come up.

Finally
-------

[](#finally)

### Testing

[](#testing)

You can run tests with the `composer test` command.

### Contributing

[](#contributing)

Feel free to create a fork and submit a pull request if you would like to contribute.

### Bug reports

[](#bug-reports)

Raise an issue on GitHub if you notice something broken.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 92.9% 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 ~118 days

Recently: every ~179 days

Total

15

Last Release

1126d ago

Major Versions

v1.3 → v2.02019-06-29

2.0.1 → 3.0.02021-02-03

PHP version history (2 changes)v1.0PHP &gt;=7.0

v3.0.6PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/f48c8f47093bb132791728e8c6d1309febbf7db4bf2f648ac38c2ae7cc37b587?d=identicon)[hackerESQ](/maintainers/hackerESQ)

---

Top Contributors

[![hackeresq](https://avatars.githubusercontent.com/u/16628119?v=4)](https://github.com/hackeresq "hackeresq (118 commits)")[![blimundo](https://avatars.githubusercontent.com/u/43821095?v=4)](https://github.com/blimundo "blimundo (3 commits)")[![markdieselcore](https://avatars.githubusercontent.com/u/16547382?v=4)](https://github.com/markdieselcore "markdieselcore (2 commits)")[![ryancwalsh](https://avatars.githubusercontent.com/u/2086493?v=4)](https://github.com/ryancwalsh "ryancwalsh (2 commits)")[![underdpt](https://avatars.githubusercontent.com/u/8122137?v=4)](https://github.com/underdpt "underdpt (2 commits)")

---

Tags

encryptionkey-valuelaravelmulti-tenantsettingslaravelSettingskeyvalue

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[akaunting/laravel-firewall

Web Application Firewall (WAF) package for Laravel

999465.8k2](/packages/akaunting-laravel-firewall)[soved/laravel-gdpr

GDPR compliance with ease

299127.5k2](/packages/soved-laravel-gdpr)[masterro/laravel-xss-filter

Filter user input for XSS but don't touch other html

41254.5k](/packages/masterro-laravel-xss-filter)[rennokki/eloquent-settings

Eloquent Settings allows you to bind key-value pairs to any Laravel Eloquent model. It supports even casting for boolean, float or integer types.

804.2k](/packages/rennokki-eloquent-settings)[orchid/settings

Settings this is key-value storage

1117.3k2](/packages/orchid-settings)[enlightn/laravel-security-checker

A Laravel package to scan your dependencies for known security vulnerabilities.

51173.4k](/packages/enlightn-laravel-security-checker)

PHPackages © 2026

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