PHPackages                             patkruk/laravel-cached-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. [Caching](/categories/caching)
4. /
5. patkruk/laravel-cached-settings

ActiveLibrary[Caching](/categories/caching)

patkruk/laravel-cached-settings
===============================

A simple cached config container for Laravel 4

1.0.6(12y ago)246855MITPHPPHP &gt;=5.3.0

Since Jan 27Pushed 11y ago2 watchersCompare

[ Source](https://github.com/patkruk/Laravel-Cached-Settings)[ Packagist](https://packagist.org/packages/patkruk/laravel-cached-settings)[ RSS](/packages/patkruk-laravel-cached-settings/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (4)Versions (4)Used By (0)

Laravel Cached Settings
=======================

[](#laravel-cached-settings)

[![Build Status](https://camo.githubusercontent.com/1b1932e67cfc3034a88da4b28d75b3fff7ac81be2d342e2b8c8c2651e2231df9/68747470733a2f2f7472617669732d63692e6f72672f7061746b72756b2f4c61726176656c2d4361636865642d53657474696e67732e706e67)](https://travis-ci.org/patkruk/Laravel-Cached-Settings.png)

Provides a basic container for your configuration parameters and settings.

Key-value pairs are stored in your database and, if cache is enabled in the package configuration file, also in your caching system. When you try to retrieve a value from the container, the caching system is always checked first and if the value exists, the database layer is never touched. In case the value is not in your cache, it's retrieved from the persistent storage and also automatically added to the caching layer.

The package uses the current environment name to oraganize settings in order to allow you have different values based on the environment the application is running in. Therefore, a value added while in "local", won't be available in "production" or "testing".

One of the artisan commands the package offers, allows you to import a json file into the persistant storage system. See below for more info.

Installation
============

[](#installation)

Add the package to your composer.json file:

```
"require": {
  "patkruk/laravel-cached-settings": "dev-master"
}

```

Use composer to install the package:

```
$ composer update

```

Pusblish a configuration file using artisan:

```
$ php artisan config:publish patkruk/laravel-cached-settings

```

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

[](#configuration)

### Registering the Package

[](#registering-the-package)

Add an alias to the bottom of app/config/app.php

```
'CachedSettings' => 'Patkruk\LaravelCachedSettings\Facades\CachedSettings',
```

and register this service provider at the bottom of the `$providers` array:

```
'Patkruk\LaravelCachedSettings\LaravelCachedSettingsServiceProvider',
```

### Running Migrations

[](#running-migrations)

```
$ php artisan migrate --package=patkruk/laravel-cached-settings

```

You can specify the table name in the published package config file.

Usage
-----

[](#usage)

### Adding a new setting:

[](#adding-a-new-setting)

```
CachedSettings::set('datetime_format', 'Y-m-d H-i-s');
```

You can use "dot" notation to imitate a multi-dimensional array:

```
CachedSettings::set('email.admin', 'admin@example.com');
CachedSettings::set('email.editor', 'editor@example.com');
```

### Retrieving a setting:

[](#retrieving-a-setting)

```
CachedSettings::get('datetime_format');
CachedSettings::get('email.editor');
CachedSettings::get('email.host', 'default_value');
```

### Checking if a setting exists:

[](#checking-if-a-setting-exists)

```
CachedSettings::has('email.admin');
```

It checks the persistent storage and returns a boolean.

### Updating a setting:

[](#updating-a-setting)

```
CachedSettings::set('email.admin', 'administrator@example.com');
```

### Deleting a setting:

[](#deleting-a-setting)

```
CachedSettings::delete('email.admin');
```

This command removes a setting from the caching and persistent storages!

### Deleting all settings:

[](#deleting-all-settings)

```
CachedSettings::deleteAll();
```

This command removes all settings from the caching and persistent storages!

### Refreshing a setting in cache:

[](#refreshing-a-setting-in-cache)

If you have changed a value directly in the database or just want to make sure that your cache is up-to-date, you can refresh individual settings.

```
CachedSettings::refresh('email.admin');
```

The value in your cache is updated with the one from the database.

### Refreshing all settings in cache:

[](#refreshing-all-settings-in-cache)

You can update your cache with the values from the database with just one command.

```
CachedSettings::refreshAll();
```

### Getting a list of all keys:

[](#getting-a-list-of-all-keys)

```
CachedSettings::getKeys();
```

This command returns an array of all keys currently stored in the database.

### Getting all key and settings:

[](#getting-all-key-and-settings)

```
CachedSettings::getKeysAndValues();
```

This command returns an associative array of all settings.

### Getting all settings (table dump):

[](#getting-all-settings-table-dump)

```
CachedSettings::getAll();
```

This command returns a dump of the entire table.

Artisan Commands
----------------

[](#artisan-commands)

The packages provides 5 different artisan commands for your convenience:

### Setting a parameter:

[](#setting-a-parameter)

```
$ php artisan cached-settings:set email.admin admin@example.com

```

Or simply run the command below and provide the needed info when asked:

```
$ php artisan cached-settings:set

```

You can always specify the environment by using the "env" option:

```
$ php artisan cached-settings:set email.admin admin@example.com --env=production

```

### Returning a parameter:

[](#returning-a-parameter)

```
$ php artisan cached-settings:get email.admin

```

Or simply:

```
$ php artisan cached-settings:get

```

### Refreshing all parameters in cache:

[](#refreshing-all-parameters-in-cache)

```
$ php artisan cached-settings:refresh-all

```

### Deleting all parameters (cache and database):

[](#deleting-all-parameters-cache-and-database)

```
$ php artisan cached-settings:delete-all

```

### Importing a JSON file:

[](#importing-a-json-file)

```
$ php artisan cached-settings:import-file /home/vagrant/import_data.json

```

This command allows you to import a file with a JSON object which has string or number fields only. Example:

```
{
    "email.admin": "admin@example.com",
    "email.editor": "editor@example.com",
    "email.send": "false",
    "security.min_password_length": 15
}

```

As always, you can specify the environment by using the "env" option:

```
$ php artisan cached-settings:import-file /home/vagrant/import_data.json --env=production

```

License
-------

[](#license)

Laravel Cached Settings is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 90% 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 ~2 days

Total

2

Last Release

4486d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9f08d1524c268b4404718a10a0a3d1f21670523f83e1c5dd39d4d0e2cc334897?d=identicon)[patkruk](/maintainers/patkruk)

---

Top Contributors

[![patkruk](https://avatars.githubusercontent.com/u/1271901?v=4)](https://github.com/patkruk "patkruk (36 commits)")[![maciekish](https://avatars.githubusercontent.com/u/442007?v=4)](https://github.com/maciekish "maciekish (3 commits)")[![valorin](https://avatars.githubusercontent.com/u/897369?v=4)](https://github.com/valorin "valorin (1 commits)")

---

Tags

laravelconfig containercached configscached settings

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.2M51](/packages/spatie-laravel-responsecache)[awssat/laravel-visits

Laravel Redis visits counter for Eloquent models

975163.6k2](/packages/awssat-laravel-visits)[namoshek/laravel-redis-sentinel

An extension of Laravels Redis driver which supports connecting to a Redis master through Redis Sentinel.

38679.0k](/packages/namoshek-laravel-redis-sentinel)[encore/redis-manager

Redis manager for laravel

25243.1k](/packages/encore-redis-manager)[dragon-code/laravel-cache

An improved interface for working with cache

6844.8k10](/packages/dragon-code-laravel-cache)[nexxai/laravel-cfcache

A handful of Cloudflare cache helpers for Laravel

1317.7k](/packages/nexxai-laravel-cfcache)

PHPackages © 2026

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