Search by

solophp / settings

Vitaliy Olos

This package is abandoned and no longer maintained. No replacement package was suggested.

Managing application settings stored in a database

Package info

github.com/SoloPHP/Settings

pkg:composer/solophp/settings

Statistics

Installs: 46

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v2.0.0 2025-08-08 17:24 UTC

This package is auto-updated.

Last update: 2026-10-28 19:39:04 UTC


README

Warning

Abandoned. This package is no longer maintained and gets no fixes. It has no successor and stays on Packagist for the projects that use it. The current Solo packages are listed at solophp.github.io.

Latest Version on Packagist License PHP Version

A simple and efficient PHP settings management package that provides an interface to store and retrieve application settings from a database.

Features

  • Easy integration with existing database connections
  • Automatic serialization and deserialization of complex data types
  • Support for both object-oriented and array-like access to settings
  • Efficient caching of settings to minimize database queries

Installation

composer require solophp/settings

Requirements

  • PHP 8.1+
  • PDO extension

Basic Setup

First, ensure that you have a table for storing settings. The table should have two columns: name (string) and value (string).

Example table schema:

CREATE TABLE `settings` (
  `name` VARCHAR(255) NOT NULL,
  `value` TEXT NOT NULL,
  PRIMARY KEY (`name`)
);

Usage

First, create an instance of the Settings class:

use Solo\Settings\Settings;

$pdo = new PDO('mysql:host=localhost;dbname=app', 'user', 'pass');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$settings = new Settings($pdo, 'settings');

Retrieving Settings

You can retrieve settings using either method calls or property access:

$value = $settings->get('my_setting');
// or
$value = $settings->my_setting;

Storing Settings

Similarly, you can store settings using either method calls or property access:

$settings->set('my_setting', 'new_value');
// or
$settings->my_setting = 'new_value';

Get all Settings

Get all settings as an associative array.:

$settings->getAll();

License

This project is licensed under the MIT License - see the LICENSE file for details.