PHPackages                             websitesql/config - 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. websitesql/config

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

websitesql/config
=================

A simple configuration management library by Website SQL.

v1.0.0(1y ago)03MITPHPPHP ^8.2

Since Apr 15Pushed 1y ago1 watchersCompare

[ Source](https://github.com/websitesql/config)[ Packagist](https://packagist.org/packages/websitesql/config)[ Docs](https://www.websitesql.com)[ RSS](/packages/websitesql-config/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

WebsiteSQL Config
=================

[](#websitesql-config)

A simple, flexible configuration management library for PHP applications. This package provides easy access to configuration files and environment variables.

Features
--------

[](#features)

- Load and parse environment variables from `.env` files
- Access configuration values from PHP files with dot notation
- Convert environment variable strings to appropriate PHP types
- Simple API for retrieving configuration values

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

[](#installation)

```
composer require websitesql/config
```

Basic Usage
-----------

[](#basic-usage)

### Setting Up

[](#setting-up)

1. Create a `.env` file in your project root:

```
APP_NAME=MyApplication
APP_ENV=local
APP_DEBUG=true
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mydatabase
DB_USERNAME=root
DB_PASSWORD=
```

2. Create PHP configuration files in a `config` directory:

```
// config/app.php
return [
    'name' => env('APP_NAME', 'WebsiteSQL'),
    'env' => env('APP_ENV', 'production'),
    'debug' => env('APP_DEBUG', false),
];

// config/database.php
return [
    'default' => env('DB_CONNECTION', 'mysql'),
    'connections' => [
        'mysql' => [
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
        ],
    ],
];
```

3. Initialize the Config class:

```
use WebsiteSQL\Config\Config;

// Pass your application's base path to the constructor
$config = new Config(__DIR__);
```

### Retrieving Configuration Values

[](#retrieving-configuration-values)

```
// Get a configuration value with dot notation
$appName = $config->get('app.name'); // Returns the value from config/app.php['name']
$dbHost = $config->get('database.connections.mysql.host'); // Nested arrays are supported

// Specify a default value if the configuration key doesn't exist
$timezone = $config->get('app.timezone', 'UTC');
```

API Reference
-------------

[](#api-reference)

### Config Class

[](#config-class)

#### `__construct(string $basePath)`

[](#__constructstring-basepath)

Initializes the Config class with the base path of your application.

- `$basePath`: The absolute path to your application's root directory.

#### `get(string $key, mixed $default = null): mixed`

[](#getstring-key-mixed-default--null-mixed)

Retrieves a configuration value using dot notation.

- `$key`: The configuration key in dot notation (e.g., 'app.name').
- `$default`: The default value to return if the key doesn't exist.

### env() Function

[](#env-function)

```
env(string $key, mixed $default = null): mixed
```

Retrieves the value of an environment variable from various sources.

- `$key`: The name of the environment variable.
- `$default`: The default value to return if the environment variable doesn't exist.

Special string values are converted automatically:

- `"true"` → `true` (boolean)
- `"false"` → `false` (boolean)
- `"null"` → `null`
- `"empty"` → `""` (empty string)

Directory Structure
-------------------

[](#directory-structure)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance47

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

Unknown

Total

1

Last Release

398d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/280e4b985f922abd667a75c49aee0c176202dcbf84464fd50de0cd9328092e60?d=identicon)[alantiller](/maintainers/alantiller)

---

Top Contributors

[![alantiller](https://avatars.githubusercontent.com/u/26198238?v=4)](https://github.com/alantiller "alantiller (1 commits)")

### Embed Badge

![Health badge](/badges/websitesql-config/health.svg)

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

###  Alternatives

[roots/bedrock

WordPress boilerplate with Composer, easier configuration, and an improved folder structure

6.5k441.8k2](/packages/roots-bedrock)[akaunting/laravel-money

Currency formatting and conversion package for Laravel

7825.3M18](/packages/akaunting-laravel-money)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

310107.9k1](/packages/cognesy-instructor-php)[blair2004/nexopos

The Free Modern Point Of Sale System build with Laravel, TailwindCSS and Vue.js.

1.2k2.3k](/packages/blair2004-nexopos)[lullabot/drainpipe

An automated build tool to allow projects to have a set standardized operations scripts.

41716.4k2](/packages/lullabot-drainpipe)[aedart/athenaeum

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

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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