Download the PHP package rcalicdan/config-loader without Composer

On this page you can find all versions of the php package rcalicdan/config-loader. 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 config-loader

ConfigLoader

A lightweight, zero-configuration PHP library for managing environment variables and configuration files with automatic project root detection.

Features

Installation

Requirements

Quick Start

Basic Usage

Using Helper Functions

The library provides global helper functions for the most common use cases. This is the recommended way to interact with the library in most applications.

Project Structure

ConfigLoader expects your project to follow this standard structure:

Configuration Files

Create PHP files in the /config directory that return an array. You can use the env() helper to load values from your .env file.

config/app.php

Environment Variables (.env)

Create a .env file in your project root. This file should not be committed to version control.

API Reference

ConfigLoader Class

The core singleton class that handles all loading and caching logic.

getInstance(): self

Gets the singleton instance of ConfigLoader.

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

Retrieves a configuration value by key. Supports dot notation for nested values.

set(string $key, mixed $value): bool

Sets a configuration value at runtime. The key must already exist. Returns true on success.

setOrFail(string $key, mixed $value): void

Sets a configuration value at runtime. Throws ConfigKeyNotFoundException if the key does not exist.

loadFromRoot(string $filename, ?string $key = null, mixed $default = null): mixed

Loads a specific configuration file from the project root directory.

has(string $key): bool

Checks if a configuration key exists using dot notation.

all(): array

Gets all loaded configuration values as a single array.

getRootPath(): ?string

Gets the auto-detected project root path.

reset(): void

Resets the singleton instance.

Config Class (Static Facade)

A static helper class that provides convenient access to the ConfigLoader instance.

Helper Functions

config(?string $key = null, mixed $default = null): mixed|ConfigLoader

The most common way to access standard configuration.

configRoot(string $filename, ?string $key = null, mixed $default = null): mixed

A helper function to load a configuration file from the project root (mirroring loadFromRoot).

env(string $key, mixed $default = null, bool $convertNumeric = false): mixed

Gets an environment variable with automatic type conversion.

Advanced Usage

Nested Configuration Directories

The library automatically loads files from subdirectories within /config and prefixes them with the directory name. For config/services/mail.php, access values via: config('services.mail.host').

Loading Files Manually (loadFromRoot)

While the library automatically scans the config/ directory, you might want to load a file located in your project root or load a file strictly on demand.

Example: Loading a payment.php file from the project root

Note on Dot Notation in loadFromRoot: If you load a file using a dot-notation key (e.g., configRoot('file', 'my.nested.key')), the library is smart enough to handle array wrapping. If your file returns ['my' => ['nested' => ['key' => ...]]] and you load it into 'my.nested.key', the library will "unwrap" the redundant nesting so you don't end up with my.nested.key.my.nested.key.

Modifying Configuration at Runtime

You can override configuration values for a single request.

Exception Handling

The library throws specific exceptions for error handling:

Testing

Use ConfigLoader::reset() or Config::reset() in your test tearDown() to ensure test isolation.


All versions of config-loader with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
vlucas/phpdotenv Version ^5.6
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 rcalicdan/config-loader contains the following files

Loading the files please wait ...