Search by

websk / php-config

websk

PHP configs wrapper

Package info

github.com/websk/php-config

Homepage

pkg:composer/websk/php-config

Statistics

Installs: 282

Dependents: 9

Suggesters: 0

Stars: 0

Open Issues: 0

2.2.0 2026-10-05 03:57 UTC

This package is auto-updated.

Last update: 2026-10-05 03:58:34 UTC


README

A small wrapper for reading values from a configuration array using dot notation.

Requirements

  • PHP 8.3 or newer, including PHP 8.5
  • Composer

Installation

composer require websk/php-config

Usage

<?php

use WebSK\Config\ConfWrapper;

ConfWrapper::setConfig([
    'settings' => [
        'displayErrorDetails' => false,
        'database' => [
            'host' => 'localhost',
        ],
    ],
]);

$host = ConfWrapper::value('settings.database.host');
$port = ConfWrapper::value('settings.database.port', 3306);

value() returns the supplied default when a key does not exist or when an intermediate value cannot be traversed. Existing null values are returned as null and are not replaced with the default. An empty path returns an empty string.

Calling setConfig() replaces the complete previously stored configuration.

Testing

Install development dependencies and run the test suite:

composer install
composer test