Download the PHP package philiprehberger/laravel-settings without Composer

On this page you can find all versions of the php package philiprehberger/laravel-settings. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-settings

Laravel Settings

Tests Latest Version on Packagist Last updated

Type-safe, cached application settings stored in the database with a simple key-value API.

Requirements

Installation

Publish and run the migration:

Optionally publish the config file:

Configuration

config/settings.php:

Usage

Increment / Decrement

Bulk Operations

Type Casting

Values are automatically cast back to their original type on retrieval.

PHP type type column Round-trips correctly
string string Yes
int int Yes
float float Yes
bool bool Yes (true/false)
array array Yes (JSON encoded)
— explicit json Yes (JSON encoded)

Default Fallback Chain

When a key is not found in the database, Settings::get() resolves in this order:

  1. config('settings.defaults.<key>') — static config defaults
  2. The $default argument passed to get()

Group Filtering

A "group" is everything before the first dot in the key name.

Per-User Settings

Each user's settings are stored with a user_id and cached independently.

Per-user settings are completely isolated from global settings. Two users can have different values for the same key, and both are independent from any global value stored without a user_id.

Cache

All settings are cached as a single serialized Collection under one key (default: app_settings). This means every read after the first is served from the cache. Any write (set, forget, flush) immediately invalidates the cache so the next read re-hydrates from the database.

Disable caching entirely in config/settings.php:

Artisan Commands

Database Schema

Column Type Notes
id bigint unsigned Primary key
key varchar Unique per user_id scope
value text Serialized value
type varchar(20) string|int|float|bool|array|json
group varchar(100) Nullable, indexed, derived from key
user_id bigint unsigned Nullable, indexed, for per-user scopes
created_at timestamp
updated_at timestamp

API

Method Description
Settings::set(string $key, mixed $value, ?string $type) Store a value (type auto-detected)
Settings::get(string $key, mixed $default) Retrieve a value with optional default
Settings::has(string $key): bool Check if a key exists
Settings::forget(string $key) Remove a key
Settings::all(?string $group): Collection Get all settings, optionally filtered by group
Settings::flush() Remove all settings
Settings::getMany(array $keys): array Retrieve multiple settings at once
Settings::setMany(array $values): void Store multiple settings at once
Settings::increment(string $key, int\|float $amount): int\|float Increment a numeric setting
Settings::decrement(string $key, int\|float $amount): int\|float Decrement a numeric setting
Settings::setForUser(int $userId, string $key, mixed $value) Store a per-user value
Settings::getForUser(int $userId, string $key, mixed $default) Retrieve a per-user value
Settings::hasForUser(int $userId, string $key): bool Check per-user key existence
Settings::forgetForUser(int $userId, string $key) Remove a per-user key
Settings::allForUser(int $userId, ?string $group): Collection Get all per-user settings
Settings::flushForUser(int $userId) Remove all per-user settings

Development

Support

If you find this project useful:

Star the repo

🐛 Report issues

💡 Suggest features

❤️ Sponsor development

🌐 All Open Source Projects

💻 GitHub Profile

🔗 LinkedIn Profile

License

MIT


All versions of laravel-settings with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/contracts Version ^11.0|^12.0
illuminate/database Version ^11.0|^12.0
illuminate/support Version ^11.0|^12.0
illuminate/cache Version ^11.0|^12.0
illuminate/console Version ^11.0|^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package philiprehberger/laravel-settings contains the following files

Loading the files please wait ...