PHPackages                             amdadulhaq/setting-laravel - 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. amdadulhaq/setting-laravel

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

amdadulhaq/setting-laravel
==========================

Setting option for Laravel

v3.0.0(2w ago)45.3kMITPHPPHP ^8.2|^8.3|^8.4|^8.5CI passing

Since Dec 4Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/amdad121/setting-laravel)[ Packagist](https://packagist.org/packages/amdadulhaq/setting-laravel)[ Docs](https://github.com/amdad121/setting-laravel)[ GitHub Sponsors](https://github.com/amdad121)[ RSS](/packages/amdadulhaq-setting-laravel/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (8)Dependencies (18)Versions (10)Used By (0)

Setting option for Laravel
==========================

[](#setting-option-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5f547e6f04d95397e7e6c9a08976a68d2fcbe4c731212ce5bd7d6a34efa96a9c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616d646164756c6861712f73657474696e672d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/amdadulhaq/setting-laravel)[![GitHub Tests Action Status](https://camo.githubusercontent.com/fe122eb9286e48320388321824770fa47c21178e60728280d0cd56399d6c432c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616d6461643132312f73657474696e672d6c61726176656c2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/amdad121/setting-laravel/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/6a40912b2eb2287156b9a20dcf1fe77dea54e9d83a0899187bbf180efad2a394/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616d6461643132312f73657474696e672d6c61726176656c2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/amdad121/setting-laravel/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/d747e6e7e84860d732daf0b5c834e70debfa430c82ef0fa004a2641b7f67240c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616d646164756c6861712f73657474696e672d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/amdadulhaq/setting-laravel)

A minimal and powerful settings package for Laravel with caching, type casting, and bulk operations.

Features
--------

[](#features)

- Simple key-value storage backed by a database table
- Automatic type casting (strings, integers, floats, booleans, `null`, arrays, JSON)
- Built-in caching, with a configurable key and TTL
- Bulk operations for setting/getting multiple values at once
- `Cache::flushSettings()` macro and manual cache flushing
- Facade and `setting()` helper function support
- Optional runtime overwriting of `config()` values from stored settings, restrictable to specific keys, automatic or manual
- Direct access to the underlying Eloquent model for raw, uncached reads/writes

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

[](#installation)

You can install the package via composer:

```
composer require amdadulhaq/setting-laravel
```

### Requirements

[](#requirements)

- PHP 8.2, 8.3, 8.4, or 8.5
- Laravel 11, 12, or 13

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="setting-laravel-migrations"
php artisan migrate
```

Optionally publish the config file:

```
php artisan vendor:publish --tag="setting-laravel-config"
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use AmdadulHaq\Setting\Facades\Setting;

Setting::set('app_name', 'Laravel');

return Setting::get('app_name');
// Laravel

Setting::remove('app_name');
// true

Setting::has('app_name');
// false
```

### Helper Function

[](#helper-function)

```
setting()->set('app_name', 'Laravel');

return setting()->get('app_name');
// Laravel

return setting()->remove('app_name');
// true
```

### Type Casting

[](#type-casting)

The package automatically casts values to their appropriate types:

```
setting()->set('string_value', 'Hello');
setting()->set('integer_value', 100);
setting()->set('float_value', 15.5);
setting()->set('boolean_value', true);
setting()->set('array_value', ['foo' => 'bar']);
setting()->set('json_value', ['nested' => ['key' => 'value']]);

setting()->get('integer_value'); // Returns: 100 (int)
setting()->get('boolean_value'); // Returns: true (bool)
setting()->get('array_value');   // Returns: ['foo' => 'bar'] (array)
```

### Default Values

[](#default-values)

```
setting()->get('nonexistent_key', 'default_value');
// default_value
```

### Bulk Operations

[](#bulk-operations)

```
// Set multiple settings at once
setting()->setMultiple([
    'app_name' => 'Laravel',
    'max_users' => 100,
    'maintenance_mode' => false,
]);

// Get multiple settings at once
$settings = setting()->getMultiple(['app_name', 'max_users']);
// ['app_name' => 'Laravel', 'max_users' => 100]
```

### Get All Settings

[](#get-all-settings)

```
$allSettings = setting()->all();
// Returns a Collection of all settings
```

### Cache Management

[](#cache-management)

```
// Manually flush the cache
setting()->flushCache();
```

Under the hood this uses a `Cache::flushSettings()` macro registered by the package, which you can also call directly:

```
Cache::flushSettings();
```

### Overwrite App Config

[](#overwrite-app-config)

Store a setting using a key that matches a config path (dot notation) to have it overwrite `config()` at runtime — useful for changing things like mail settings, feature limits, or third-party keys without redeploying:

```
setting()->set('mail.from.address', 'hello@example.com');

setting()->overwriteConfig();

config('mail.from.address');
// hello@example.com
```

Restrict which keys get applied by passing an explicit list:

```
setting()->overwriteConfig(['mail.from.address', 'app.name']);
```

Enable `SETTING_OVERWRITE_CONFIG=true` in your `.env` to have this applied automatically on every request boot (once the `settings` table exists):

```
SETTING_OVERWRITE_CONFIG=true
```

To restrict the automatic, boot-time overwrite to specific keys, publish the config file and set `overwrite_config_keys`. Leave it empty to apply every stored setting that matches a config path:

```
// config/setting.php
'overwrite_config_keys' => ['mail.from.address', 'app.name'],
```

### Using the Model Directly

[](#using-the-model-directly)

The underlying Eloquent model also exposes simple static helpers, if you'd rather bypass caching and type casting:

```
use AmdadulHaq\Setting\Models\Setting;

Setting::set('app_name', 'Laravel');   // stores the raw string
Setting::get('app_name');              // 'Laravel' (always string|null)
Setting::remove('app_name');           // true
```

Configuration
-------------

[](#configuration)

Publish the config file to customize caching behavior and config overwriting:

```
php artisan vendor:publish --tag="setting-laravel-config"
```

```
return [
    // Whether settings are cached, and for how long.
    'cache_enabled' => env('SETTING_CACHE_ENABLED', true),
    'cache_key' => env('SETTING_CACHE_KEY', 'settings.cache'),
    'cache_ttl' => env('SETTING_CACHE_TTL', 60 * 60 * 24), // 24 hours

    // Automatically overwrite config() with matching stored settings on boot.
    'overwrite_config' => env('SETTING_OVERWRITE_CONFIG', false),

    // Restrict automatic overwriting to these keys; empty applies all.
    'overwrite_config_keys' => [],
];
```

OptionEnv variableDefaultDescription`cache_enabled``SETTING_CACHE_ENABLED``true`Cache settings in the configured cache store.`cache_key``SETTING_CACHE_KEY``settings.cache`Cache key used to store all settings.`cache_ttl``SETTING_CACHE_TTL``86400`Cache lifetime in seconds.`overwrite_config``SETTING_OVERWRITE_CONFIG``false`Automatically apply stored settings onto `config()` on every boot.`overwrite_config_keys`—`[]`Limit automatic overwriting to these setting keys (array, set in the published config file).API Reference
-------------

[](#api-reference)

MethodDescription`get(string $key, mixed $default = null): mixed`Get a setting, type-cast to its original value.`set(string $key, mixed $value): Setting`Create or update a setting, returning the model.`remove(string $key): bool`Delete a setting; `true` if a row was deleted.`has(string $key): bool`Check whether a setting exists.`all(): Collection`Get every setting as a `key => value` collection.`setMultiple(array $settings): void`Create or update several settings at once.`getMultiple(array $keys, mixed $default = null): array`Get several settings at once, as `key => value`.`flushCache(): void`Manually forget the cached settings collection.`overwriteConfig(?array $keys = null): void`Apply stored settings onto `config()`, optionally restricted to `$keys`.Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Amdadul Haq](https://github.com/amdad121)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance84

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

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

Recently: every ~125 days

Total

9

Last Release

20d ago

Major Versions

v1.2.1 → v2.0.02026-01-01

v2.2.0 → v3.0.02026-07-21

PHP version history (2 changes)v1.0.0PHP ^8.1

v2.0.0PHP ^8.2|^8.3|^8.4|^8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/7219b32db58e53dddb8a970aec40c9a41ec7d6dbf3570fd89ac14abe7424532e?d=identicon)[amdadulhaq](/maintainers/amdadulhaq)

---

Top Contributors

[![amdad121](https://avatars.githubusercontent.com/u/11732880?v=4)](https://github.com/amdad121 "amdad121 (27 commits)")

---

Tags

configurationlaravelsettingslaravelAmdadul Haqsetting-laravel

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/amdadulhaq-setting-laravel/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[laravel/ai

The official AI SDK for Laravel.

1.1k4.6M293](/packages/laravel-ai)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[illuminate/queue

The Illuminate Queue package.

20433.0M1.8k](/packages/illuminate-queue)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45844.8k1](/packages/pressbooks-pressbooks)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5226.7k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

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