PHPackages                             pico/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. pico/settings

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

pico/settings
=============

A Laravel package for key-value settings, supporting user-specific and model-specific configurations.

1.0.4(3mo ago)019MITPHPPHP ^8.3

Since Apr 10Pushed 3mo agoCompare

[ Source](https://github.com/s1k3/laravel-pico-settings)[ Packagist](https://packagist.org/packages/pico/settings)[ RSS](/packages/pico-settings/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (5)Dependencies (6)Versions (6)Used By (0)

Pico Settings
=============

[](#pico-settings)

A lightweight Laravel package for managing key-value settings. Supports global, user-specific, and model-specific scopes with optional JSON file caching.

**Requirements:** PHP 8.3+ · Laravel 11 or 12 or 13

---

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

[](#installation)

```
composer require pico/settings
```

Publish the config file:

```
php artisan vendor:publish --tag=pico-settings-config
```

Generate and run the migration:

```
php artisan pico:settings-table-migration
php artisan migrate
```

This creates a timestamped `create_settings_table` migration in your `database/migrations/` directory.

If you want to customise the stub before generating, publish it first:

```
php artisan vendor:publish --tag=pico-settings-stubs
```

The stub will be placed at `stubs/pico-settings/create_settings_table.stub` and `pico:settings-table-migration` will use it automatically.

---

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

[](#configuration)

`config/pico-settings.php`

```
return [

    // The table name used for the users foreign key
    'user_table' => 'users',

    'cache' => [
        // Enable JSON file caching (recommended for production)
        'enabled' => true,

        // Directory where per-scope JSON cache files are stored
        'path' => storage_path('app/pico-settings'),
    ],

];
```

---

Usage
-----

[](#usage)

### Facade

[](#facade)

```
use Pico\Settings\Facades\Settings;
```

### Helper function

[](#helper-function)

```
settings()
```

---

### Global settings

[](#global-settings)

```
// Set a single value
Settings::set('maintenance_mode', 'false');

// Set multiple values at once
Settings::set(['theme' => 'dark', 'locale' => 'en']);

// Get a single value (with optional default)
Settings::get('theme');            // 'dark'
Settings::get('missing', 'light'); // 'light'

// Get multiple values at once
Settings::get(['theme', 'locale']);
// ['theme' => 'dark', 'locale' => 'en']
```

---

### User-specific settings

[](#user-specific-settings)

```
$user = auth()->user();

Settings::for($user)->set('locale', 'fr');
Settings::for($user)->set(['locale' => 'fr', 'timezone' => 'Europe/Paris']);

Settings::for($user)->get('locale');             // 'fr'
Settings::for($user)->get('missing', 'en');      // 'en'
Settings::for($user)->get(['locale', 'timezone']);
// ['locale' => 'fr', 'timezone' => 'Europe/Paris']
```

---

### Model-specific settings

[](#model-specific-settings)

```
use App\Models\Post;

Settings::model(Post::class)->set('per_page', '20');
Settings::model(Post::class)->get('per_page'); // '20'
```

You can also pass a model instance:

```
$post = Post::find(1);
Settings::model($post)->set('featured', 'true');
```

---

### Combined scope (user + model)

[](#combined-scope-user--model)

```
Settings::for($user)->model(Post::class)->set('view', 'grid');
Settings::for($user)->model(Post::class)->get('view'); // 'grid'

// Scopes are isolated — other scopes are unaffected
Settings::for($user)->get('view');              // null
Settings::model(Post::class)->get('view');      // null
```

---

### Using the helper

[](#using-the-helper)

```
settings()->for($user)->model(Post::class)->get('view', 'list');
settings()->for($user)->set(['locale' => 'en', 'timezone' => 'UTC']);
```

---

### Deleting settings

[](#deleting-settings)

```
// Delete a single key
Settings::delete('theme');

// Delete multiple keys
Settings::delete(['theme', 'locale']);

// Delete all keys in the current scope
Settings::delete();

// Delete within a user scope
Settings::for($user)->delete('locale');

// Delete within a combined user + model scope
Settings::for($user)->model(Post::class)->delete('view');
```

Deleting only affects the targeted scope — other scopes are left untouched.

---

Caching
-------

[](#caching)

When caching is enabled, settings are stored in JSON files under `storage/app/pico-settings/` (configurable). Each scope gets its own file:

ScopeFileGlobal`global.json`User only`user_1.json`Model only`model_posts.json`User + model`user_1_model_posts.json`On every `set()` call, the database is written first and then the cache file is rebuilt. On the first `get()` after boot (cache miss), the full scope is loaded from DB and written to the cache.

### Clearing the cache

[](#clearing-the-cache)

To delete all JSON cache files at once:

```
php artisan pico:clear
```

To disable caching (e.g. in tests):

```
// config/pico-settings.php
'cache' => [
    'enabled' => false,
],
```

---

Database schema
---------------

[](#database-schema)

ColumnTypeNotes`id`bigintPrimary key`user_id`bigint (nullable)FK → users table`model`string (nullable)Fully-qualified class name`key`stringSetting key`value`longTextSetting value`created_at`timestamp`updated_at`timestampA unique constraint is enforced on `(user_id, model, key)`.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance80

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity53

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

Total

5

Last Release

104d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/19550001?v=4)[Robin Khan](/maintainers/s1k3)[@s1k3](https://github.com/s1k3)

---

Top Contributors

[![s1k3](https://avatars.githubusercontent.com/u/19550001?v=4)](https://github.com/s1k3 "s1k3 (10 commits)")

---

Tags

laravelconfigurationSettingsKey value

###  Code Quality

TestsPest

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k96.5k1](/packages/mike-bronner-laravel-model-caching)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[flarum/core

Delightfully simple forum software.

211.4M2.4k](/packages/flarum-core)[api-platform/laravel

API Platform support for Laravel

58174.6k17](/packages/api-platform-laravel)

PHPackages © 2026

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