From 5e941076d06fe8a6b5234af839f9ebb3446afc85 Mon Sep 17 00:00:00 2001 From: colinodell Date: Fri, 20 Dec 2024 00:16:30 +0000 Subject: [PATCH] jekyll build from Action 708b87250055f20a21cc6dbe232369b79a71a4fa --- .nojekyll | 0 1.0/basic-usage/index.html | 287 ++++++++++++++++++++++ 1.0/changelog/index.html | 231 ++++++++++++++++++ 1.0/index.html | 244 +++++++++++++++++++ 1.0/installation/index.html | 236 ++++++++++++++++++ 1.0/lazy-processing/index.html | 266 ++++++++++++++++++++ 1.0/mutability/index.html | 240 ++++++++++++++++++ 1.0/philosophy/index.html | 271 +++++++++++++++++++++ 1.0/reading-values/index.html | 269 +++++++++++++++++++++ 1.0/schemas/index.html | 327 +++++++++++++++++++++++++ 1.0/setting-values/index.html | 293 ++++++++++++++++++++++ 1.1/basic-usage/index.html | 285 ++++++++++++++++++++++ 1.1/changelog/index.html | 229 ++++++++++++++++++ 1.1/index.html | 242 +++++++++++++++++++ 1.1/installation/index.html | 234 ++++++++++++++++++ 1.1/lazy-processing/index.html | 264 ++++++++++++++++++++ 1.1/mutability/index.html | 238 ++++++++++++++++++ 1.1/philosophy/index.html | 269 +++++++++++++++++++++ 1.1/reading-values/index.html | 267 ++++++++++++++++++++ 1.1/schemas/index.html | 325 +++++++++++++++++++++++++ 1.1/setting-values/index.html | 291 ++++++++++++++++++++++ 1.1/upgrading/index.html | 231 ++++++++++++++++++ CNAME | 1 + README.md | 7 + changelog/index.html | 50 ++++ custom.css | 430 +++++++++++++++++++++++++++++++++ custom.js | 18 ++ global.css | 42 ++++ homepage.css | 380 +++++++++++++++++++++++++++++ index.html | 193 +++++++++++++++ redirects.json | 1 + releases/index.html | 214 ++++++++++++++++ support.css | 112 +++++++++ upgrading/index.html | 50 ++++ 34 files changed, 7037 insertions(+) create mode 100644 .nojekyll create mode 100644 1.0/basic-usage/index.html create mode 100644 1.0/changelog/index.html create mode 100644 1.0/index.html create mode 100644 1.0/installation/index.html create mode 100644 1.0/lazy-processing/index.html create mode 100644 1.0/mutability/index.html create mode 100644 1.0/philosophy/index.html create mode 100644 1.0/reading-values/index.html create mode 100644 1.0/schemas/index.html create mode 100644 1.0/setting-values/index.html create mode 100644 1.1/basic-usage/index.html create mode 100644 1.1/changelog/index.html create mode 100644 1.1/index.html create mode 100644 1.1/installation/index.html create mode 100644 1.1/lazy-processing/index.html create mode 100644 1.1/mutability/index.html create mode 100644 1.1/philosophy/index.html create mode 100644 1.1/reading-values/index.html create mode 100644 1.1/schemas/index.html create mode 100644 1.1/setting-values/index.html create mode 100644 1.1/upgrading/index.html create mode 100644 CNAME create mode 100644 README.md create mode 100644 changelog/index.html create mode 100644 custom.css create mode 100644 custom.js create mode 100644 global.css create mode 100644 homepage.css create mode 100644 index.html create mode 100644 redirects.json create mode 100644 releases/index.html create mode 100644 support.css create mode 100644 upgrading/index.html diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/1.0/basic-usage/index.html b/1.0/basic-usage/index.html new file mode 100644 index 0000000..3a73174 --- /dev/null +++ b/1.0/basic-usage/index.html @@ -0,0 +1,287 @@ + + + + + + + + + + + + + + + + + Basic Usage - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + + + + + + + + +
+
+ + + +

This is the documentation for version 1.0. Please consider upgrading your code to the latest stable version

+ + + + +

Basic Usage

+ +

There are three steps to using this library:

+ + + +

Example

+ +

Simply define your configuration schema, set the values, and then fetch them where needed:

+ +
use League\Config\Configuration;
+use Nette\Schema\Expect;
+
+// Define your configuration schema
+$config = new Configuration([
+    'database' => Expect::structure([
+        'driver' => Expect::anyOf('mysql', 'postgresql', 'sqlite')->required(),
+        'host' => Expect::string()->default('localhost'),
+        'port' => Expect::int()->min(1)->max(65535),
+        'ssl' => Expect::bool(),
+        'database' => Expect::string()->required(),
+        'username' => Expect::string()->required(),
+        'password' => Expect::string()->nullable(),
+    ]),
+    'logging' => Expect::structure([
+        'enabled' => Expect::bool()->default($_ENV['DEBUG'] == true),
+        'file' => Expect::string()->deprecated("use logging.path instead"),
+        'path' => Expect::string()->assert(function ($path) { return \is_writeable($path); })->required(),
+    ]),
+]);
+
+// Set the values somewhere
+$userProvidedValues = [
+    'database' => [
+        'driver' => 'mysql',
+        'port' => 3306,
+        'host' => 'localhost',
+        'database' => 'myapp',
+        'username' => 'myappdotcom',
+        'password' => 'hunter2',
+    ],
+    'logging' => [
+        'path' => '/var/log/myapp.log',
+    ],
+];
+
+// Merge those values into your configuration schema:
+$config->merge($userProvidedValues);
+
+// Read the values and do stuff with them
+if ($config->get('logging.enabled')) {
+    file_put_contents($config->get('logging.path'), 'Connecting to the database on ' . $config->get('database.host'));
+}
+
+ + +
+ +

+ Edit this page +

+
+ + +
+ + + + + + + + diff --git a/1.0/changelog/index.html b/1.0/changelog/index.html new file mode 100644 index 0000000..73c6525 --- /dev/null +++ b/1.0/changelog/index.html @@ -0,0 +1,231 @@ + + + + + + + + + + + + + + + + + Changelog - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + + + + + + + + +
+ + + +
+ + + + + + + + diff --git a/1.0/index.html b/1.0/index.html new file mode 100644 index 0000000..bdb8b4f --- /dev/null +++ b/1.0/index.html @@ -0,0 +1,244 @@ + + + + + + + + + + + + + + + + + Overview - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + + + + + + + + +
+
+ + + +

This is the documentation for version 1.0. Please consider upgrading your code to the latest stable version

+ + + + +

Overview

+ +

Author +Latest Version +Total Downloads +Software License +Build Status +Coverage Status +Quality Score

+ +

league/config helps you define configuration arrays with strict schemas and easy access to values with dot notation.

+ +

Installation & Usage

+ +

This library can be installed via Composer:

+ +
composer require league/config
+
+ +

See the installation section for more details, then check out the basic usage section for an example to get you started.

+ + +
+ +

+ Edit this page +

+
+ + +
+ + + + + + + + diff --git a/1.0/installation/index.html b/1.0/installation/index.html new file mode 100644 index 0000000..e468970 --- /dev/null +++ b/1.0/installation/index.html @@ -0,0 +1,236 @@ + + + + + + + + + + + + + + + + + Installation - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + + + + + + + + +
+
+ + + +

This is the documentation for version 1.0. Please consider upgrading your code to the latest stable version

+ + + + +

Installation

+ +

The recommended installation method is via Composer.

+ +
composer require "league/config:^1.0"
+
+ +

Ensure that you’ve set up your project to autoload Composer-installed packages.

+ +

Versioning

+ +

SemVer will be followed closely. It’s highly recommended that you use Composer’s caret operator to ensure compatibility; for example: ^1.0. This is equivalent to >=1.0 <2.0.

+ + +
+ +

+ Edit this page +

+
+ + +
+ + + + + + + + diff --git a/1.0/lazy-processing/index.html b/1.0/lazy-processing/index.html new file mode 100644 index 0000000..42ba4e5 --- /dev/null +++ b/1.0/lazy-processing/index.html @@ -0,0 +1,266 @@ + + + + + + + + + + + + + + + + + Lazy Processing - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + + + + + + + + +
+
+ + + +

This is the documentation for version 1.0. Please consider upgrading your code to the latest stable version

+ + + + +

Lazy Processing

+ +

We delay the processing and validation of the user-provided values until the first time you attempt to read or check a value. This provides flexibility as to when the schemas and user-provided values are set.

+ +

For example, you might need to set the values from different sources. Thanks to lazy processing we won’t actually validate the schema until you try to access a value. Because of this, you might not know there’s a validation issue until you attempt to read a value:

+ +
use League\Config\Configuration;
+use Nette\Schema\Expect;
+
+$config = new Configuration([
+    'debug_mode' => Expect::bool()->required(),
+    'database' => Expect::structure([
+        'driver' => Expect::anyOf('mysql', 'postgresql', 'sqlite')->required(),
+        'host' => Expect::string()->default('localhost'),
+        'port' => Expect::int()->min(1)->max(65535),
+        'ssl' => Expect::bool(),
+        'database' => Expect::string()->required(),
+        'username' => Expect::string()->required(),
+        'password' => Expect::string()->nullable(),
+    ]),
+    'logging' => Expect::structure([
+        'enabled' => Expect::bool()->default($_ENV['DEBUG'] == true),
+        'file' => Expect::string()->deprecated("use logging.path instead"),
+        'path' => Expect::string()->assert(function ($path) { return \is_writeable($path); })->required(),
+    ]),
+]);
+
+// Load configuration from a file.
+// For the sake of this example, let's assume the user didn't set 'debug_mode'.
+// Even though this is a required option, we don't validate the schema immediately so you can add it later.
+$config->merge(json_decode(file_get_contents('database.json'), true));
+
+if ($_ENV['APP_ENV'] === 'prod') {
+    $config->set('debug_mode', false);
+    $config->merge(json_decode(file_get_contents('config.prod.json'), true));
+}
+
+// This call below will throw an exception if "debug_mode" wasn't set at all
+if ($config->get('debug_mode')) {
+    // ...
+}
+
+ + +
+ +

+ Edit this page +

+
+ + +
+ + + + + + + + diff --git a/1.0/mutability/index.html b/1.0/mutability/index.html new file mode 100644 index 0000000..ef9c097 --- /dev/null +++ b/1.0/mutability/index.html @@ -0,0 +1,240 @@ + + + + + + + + + + + + + + + + + Mutability - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + + + + + + + + +
+
+ + + +

This is the documentation for version 1.0. Please consider upgrading your code to the latest stable version

+ + + + +

Mutability

+ +

Thanks to lazy processing, you can define schemas and set user-provided values at any time and in any order. This can be very convenient in many cases, but you might have times where you’d like to provide a read-only version of the Configuration to ensure nobody else can modify it.

+ +

Read-Only Reader

+ +

To do this, simply call $config->reader(). This will return an object that only has the get() and exists() methods, preventing others from further modifying the configuration:

+ +
use League\Config\Configuration;
+
+$config = new Configuration([/* ... */]);
+
+$someOtherObject->setConfig($config->reader());
+
+ +

Because both the reader and the main Configuration implement ConfigurationInterface, you can type-hint against that anywhere you need to retrieve values but not necessarily modify things.

+ + +
+ +

+ Edit this page +

+
+ + +
+ + + + + + + + diff --git a/1.0/philosophy/index.html b/1.0/philosophy/index.html new file mode 100644 index 0000000..b0bdac4 --- /dev/null +++ b/1.0/philosophy/index.html @@ -0,0 +1,271 @@ + + + + + + + + + + + + + + + + + Philosophy - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + + + + + + + + +
+
+ + + +

This is the documentation for version 1.0. Please consider upgrading your code to the latest stable version

+ + + + +

Philosophy

+ +

There are lots of great configuration libraries out there, each one serving a slightly different purpose. As a result, this library aims to satisfy a particular niche not being served well by others by taking a simple yet opinionated approach to configuration with the following goals:

+ +
    +
  • The configuration should operate on arrays with nested values which are easily accessible
  • +
  • The configuration structure should be defined with strict schemas defining the overall structure, allowed types, and allowed values
  • +
  • Schemas should be defined using a simple, fluent interface
  • +
  • You should be able to add and combine schemas but never modify existing ones
  • +
  • Both the configuration values and the schema should be defined and managed with PHP code
  • +
  • Schemas should be immutable; they should never change once they are set
  • +
  • Configuration values should never define or influence the schemas
  • +
+ +

As a result, this library will likely never support features like:

+ +
    +
  • Loading and/or exporting configuration values or schemas using YAML, XML, or other files +
      +
    • You can still implement this yourself, if needed
    • +
    +
  • +
  • Parsing configuration values from a command line or other user interface
  • +
  • Dynamically changing the schema, allowed values, or default values based on other configuration values
  • +
+ +

If you need that functionality you should check out other great libraries like:

+ + + +

Dependencies

+ +

To help facilitate this approach, we heavily rely on the following two open-source libraries under-the-hood:

+ + + +

These were chosen specifically for being minimal, well-written, and unlikely to conflict with other dependencies you might have installed.

+ + + +
+ +

+ Edit this page +

+
+ + +
+ + + + + + + + diff --git a/1.0/reading-values/index.html b/1.0/reading-values/index.html new file mode 100644 index 0000000..905f46c --- /dev/null +++ b/1.0/reading-values/index.html @@ -0,0 +1,269 @@ + + + + + + + + + + + + + + + + + Reading Validated Options - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + + + + + + + + +
+
+ + + +

This is the documentation for version 1.0. Please consider upgrading your code to the latest stable version

+ + + + +

Reading Validated Options

+ +

Once the schema has been defined and the user options have been set you are ready to read them elsewhere in your application! Thanks to lazy processing, this library will apply the schemas and validations only if/when you attempt to read a value.

+ +

The processed, validated configuration options can be read using the get() method. Simply pass in the name of the option you wish to fetch:

+ +
use League\Config\Configuration;
+use Nette\Schema\Expect;
+
+$config = new Configuration([
+    'debug_mode' => Expect::bool()->required(),
+    'database' => Expect::structure([
+        'driver' => Expect::anyOf('mysql', 'postgresql', 'sqlite')->required(),
+        'host' => Expect::string()->default('localhost'),
+        'port' => Expect::int()->min(1)->max(65535),
+        'ssl' => Expect::bool(),
+        'database' => Expect::string()->required(),
+        'username' => Expect::string()->required(),
+        'password' => Expect::string()->nullable(),
+    ]),
+    'logging' => Expect::structure([
+        'enabled' => Expect::bool()->default($_ENV['DEBUG'] == true),
+        'file' => Expect::string()->deprecated("use logging.path instead"),
+        'path' => Expect::string()->assert(function ($path) { return \is_writeable($path); })->required(),
+    ]),
+]);
+
+// TODO: Set the configuration values
+$config->merge([/* ... */]);
+
+var_dump($config->get('debug_mode')); // a string
+var_dump($config->get('database'));   // an array
+
+ +

You can access nested options using “dot access” expressions like this:

+ +
var_dump($config->get('database.driver')); // a string
+
+// slashes can also be used instead of dots:
+var_dump($config->get('database/driver')); // a string
+
+ +

Undefined Options

+ +

If you attempt to get() an option that was not defined in the schema an exception will be thrown. This is probably not an issue in cases where you wrote the schema and know it should always contain certain options. But in some cases (perhaps you’re conditionally adding certain schemas) you might want to first check whether an option is defined before attempting to read it - you can do that with the exists() method. It takes the same arguments as get() but will return true or false based on whether that item exists.

+ + +
+ +

+ Edit this page +

+
+ + +
+ + + + + + + + diff --git a/1.0/schemas/index.html b/1.0/schemas/index.html new file mode 100644 index 0000000..0c6d0b2 --- /dev/null +++ b/1.0/schemas/index.html @@ -0,0 +1,327 @@ + + + + + + + + + + + + + + + + + Schemas - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + + + + + + + + +
+
+ + + +

This is the documentation for version 1.0. Please consider upgrading your code to the latest stable version

+ + + + +

Configuration Schemas

+ +

A “schema” defines the exact structure of arrays, keys, and values that users can configure. By using a schema, you can:

+ +
    +
  • Enforce that certain expected options are set by marking them required
  • +
  • Provide default values when none are provided by the user
  • +
  • Validate that values are certain types, numbers within ranges, match regular expressions, or contain specific sets of values (like enums)
  • +
  • Mark old options as deprecated
  • +
  • Cast values to certain types, including both scalars and custom objects
  • +
+ +

This library includes the nette/schema package to define and process the schemas. You use their Expect class to define the schemas, passing those into our library which handles all of the processing for you. You can find some example of that below, but we highly recommending reading their documentation for complete details on all the options available to you.

+ +

Example

+ +
use League\Config\Configuration;
+use Nette\Schema\Expect;
+
+// Define your configuration schema
+$config = new Configuration([
+    'debug_mode' => Expect::bool(),
+    'database' => Expect::structure([
+        'driver' => Expect::anyOf('mysql', 'postgresql', 'sqlite')->required(),
+        'host' => Expect::string()->default('localhost'),
+        'port' => Expect::int()->min(1)->max(65535),
+        'ssl' => Expect::bool(),
+        'database' => Expect::string()->required(),
+        'username' => Expect::string()->required(),
+        'password' => Expect::string()->nullable(),
+    ]),
+    'logging' => Expect::structure([
+        'enabled' => Expect::bool()->default($_ENV['DEBUG'] == true),
+        'file' => Expect::string()->deprecated("use logging.path instead"),
+        'path' => Expect::string()->assert(function ($path) { return \is_writeable($path); })->required(),
+    ]),
+]);
+
+ +

Tip: By default, nette/schema assumes that nested options (Expect::structure) will be cast to stdClass objects, but we automatically cast those to array instead, so don’t worry about doing that yourself.

+ +

Merging Schemas

+ +

You might have different systems or components that define their own schemas:

+ +
use Nette\Schema\Expect;use Nette\Schema\Schema;
+
+class DatabaseConnection
+{
+    public static function getSchema(): Schema
+    {
+        return Expect::structure([
+            'driver' => Expect::anyOf('mysql', 'postgresql', 'sqlite')->required(),
+            'host' => Expect::string()->default('localhost'),
+            'port' => Expect::int()->min(1)->max(65535),
+            'ssl' => Expect::bool(),
+            'database' => Expect::string()->required(),
+            'username' => Expect::string()->required(),
+            'password' => Expect::string()->nullable(),
+        ]);
+    }
+}
+
+class Logger
+{
+    public static function getSchema(): Schema
+    {
+        return Expect::structure([
+            'enabled' => Expect::bool()->default($_ENV['DEBUG'] == true),
+            'file' => Expect::string()->deprecated("use logging.path instead"),
+            'path' => Expect::string()->assert(function ($path) { return \is_writeable($path); })->required(),
+        ]);
+    }
+}
+
+ +

You can combine these into a single Configuration using the constructor and/or the addSchema() method. All three examples in the snippet below will achieve the same result:

+ +
use League\Config\Configuration;
+
+$config = new Configuration([
+    'database' => DatabaseConnection::getSchema(),
+    'logging' => Logger::getSchema(),
+]);
+
+// or
+
+$config = new Configuration([
+    'database' => DatabaseConnection::getSchema(),
+]);
+
+$config->addSchema('logging', Logger::getSchema());
+
+// or
+
+$config = new Configuration();
+$config->addSchema('database', DatabaseConnection::getSchema());
+$config->addSchema('logging', Logger::getSchema());
+
+ +

Schema Types

+ +

See the nette/schema documentation for full details on the different Expect options you can use to define different types of schemas.

+ + +
+ +

+ Edit this page +

+
+ + +
+ + + + + + + + diff --git a/1.0/setting-values/index.html b/1.0/setting-values/index.html new file mode 100644 index 0000000..643325b --- /dev/null +++ b/1.0/setting-values/index.html @@ -0,0 +1,293 @@ + + + + + + + + + + + + + + + + + Setting User-Provided Values - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + + + + + + + + +
+
+ + + +

This is the documentation for version 1.0. Please consider upgrading your code to the latest stable version

+ + + + +

Setting User-Provided Values

+ +

Once your schema has been defined you can apply user-provided configuration values. There are two methods available to do this:

+ +
    +
  • set($key, $value) - Define a single value
  • +
  • merge($values) - Define multiple values in one call
  • +
+ +

Example

+ +

Let’s take the following configuration as an example:

+ +
use League\Config\Configuration;
+use Nette\Schema\Expect;
+
+$config = new Configuration([
+    'debug_mode' => Expect::bool()->required(),
+    'database' => Expect::structure([
+        'driver' => Expect::anyOf('mysql', 'postgresql', 'sqlite')->required(),
+        'host' => Expect::string()->default('localhost'),
+        'port' => Expect::int()->min(1)->max(65535),
+        'ssl' => Expect::bool(),
+        'database' => Expect::string()->required(),
+        'username' => Expect::string()->required(),
+        'password' => Expect::string()->nullable(),
+    ]),
+    'logging' => Expect::structure([
+        'enabled' => Expect::bool()->default($_ENV['DEBUG'] == true),
+        'file' => Expect::string()->deprecated("use logging.path instead"),
+        'path' => Expect::string()->assert(function ($path) { return \is_writeable($path); })->required(),
+    ]),
+]);
+
+ +

You could set everything at once like this:

+ +
$config->merge([
+    'debug_mode' => false,
+    'database' => [
+        'driver' => 'mysql',
+        'port' => 3306,
+        'database' => 'myapp',
+        'username' => 'myapp_user',
+        'password' => 'hunter2',
+    ],
+    'logging' => [
+        'enabled' => true,
+        'file' => '/var/log/myapp.log',
+    ],
+]);
+
+ +

Maybe that array of data comes from a different file or method:

+ +
$config->merge(getUserConfig());
+
+// or
+
+$config->merge(json_decode(file_get_contents('database.json'), true));
+
+ +

Options can also be set individually, if needed:

+ +
// Load config from a json file...
+$config->merge(json_decode(file_get_contents('database.json'), true));
+// But override a certain setting
+$config->set('debug_mode', false);
+
+ + +
+ +

+ Edit this page +

+
+ + +
+ + + + + + + + diff --git a/1.1/basic-usage/index.html b/1.1/basic-usage/index.html new file mode 100644 index 0000000..8ae4cb2 --- /dev/null +++ b/1.1/basic-usage/index.html @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + Basic Usage - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + + + + + + + + +
+
+ + + + + + +

Basic Usage

+ +

There are three steps to using this library:

+ + + +

Example

+ +

Simply define your configuration schema, set the values, and then fetch them where needed:

+ +
use League\Config\Configuration;
+use Nette\Schema\Expect;
+
+// Define your configuration schema
+$config = new Configuration([
+    'database' => Expect::structure([
+        'driver' => Expect::anyOf('mysql', 'postgresql', 'sqlite')->required(),
+        'host' => Expect::string()->default('localhost'),
+        'port' => Expect::int()->min(1)->max(65535),
+        'ssl' => Expect::bool(),
+        'database' => Expect::string()->required(),
+        'username' => Expect::string()->required(),
+        'password' => Expect::string()->nullable(),
+    ]),
+    'logging' => Expect::structure([
+        'enabled' => Expect::bool()->default($_ENV['DEBUG'] == true),
+        'file' => Expect::string()->deprecated("use logging.path instead"),
+        'path' => Expect::string()->assert(function ($path) { return \is_writeable($path); })->required(),
+    ]),
+]);
+
+// Set the values somewhere
+$userProvidedValues = [
+    'database' => [
+        'driver' => 'mysql',
+        'port' => 3306,
+        'host' => 'localhost',
+        'database' => 'myapp',
+        'username' => 'myappdotcom',
+        'password' => 'hunter2',
+    ],
+    'logging' => [
+        'path' => '/var/log/myapp.log',
+    ],
+];
+
+// Merge those values into your configuration schema:
+$config->merge($userProvidedValues);
+
+// Read the values and do stuff with them
+if ($config->get('logging.enabled')) {
+    file_put_contents($config->get('logging.path'), 'Connecting to the database on ' . $config->get('database.host'));
+}
+
+ + +
+ +

+ Edit this page +

+
+ + +
+ + + + + + + + diff --git a/1.1/changelog/index.html b/1.1/changelog/index.html new file mode 100644 index 0000000..29a950f --- /dev/null +++ b/1.1/changelog/index.html @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + Changelog - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + + + + + + + + +
+ + + +
+ + + + + + + + diff --git a/1.1/index.html b/1.1/index.html new file mode 100644 index 0000000..61f87c5 --- /dev/null +++ b/1.1/index.html @@ -0,0 +1,242 @@ + + + + + + + + + + + + + + + + + Overview - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + + + + + + + + +
+
+ + + + + + +

Overview

+ +

Author +Latest Version +Total Downloads +Software License +Build Status +Coverage Status +Quality Score

+ +

league/config helps you define configuration arrays with strict schemas and easy access to values with dot notation.

+ +

Installation & Usage

+ +

This library can be installed via Composer:

+ +
composer require league/config
+
+ +

See the installation section for more details, then check out the basic usage section for an example to get you started.

+ + +
+ +

+ Edit this page +

+
+ + +
+ + + + + + + + diff --git a/1.1/installation/index.html b/1.1/installation/index.html new file mode 100644 index 0000000..7872715 --- /dev/null +++ b/1.1/installation/index.html @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + Installation - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + + + + + + + + +
+
+ + + + + + +

Installation

+ +

The recommended installation method is via Composer.

+ +
composer require "league/config:^1.1"
+
+ +

Ensure that you’ve set up your project to autoload Composer-installed packages.

+ +

Versioning

+ +

SemVer will be followed closely. It’s highly recommended that you use Composer’s caret operator to ensure compatibility; for example: ^1.1. This is equivalent to >=1.1 <2.0.

+ + +
+ +

+ Edit this page +

+
+ + +
+ + + + + + + + diff --git a/1.1/lazy-processing/index.html b/1.1/lazy-processing/index.html new file mode 100644 index 0000000..079847e --- /dev/null +++ b/1.1/lazy-processing/index.html @@ -0,0 +1,264 @@ + + + + + + + + + + + + + + + + + Lazy Processing - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + + + + + + + + +
+
+ + + + + + +

Lazy Processing

+ +

We delay the processing and validation of the user-provided values until the first time you attempt to read or check a value. This provides flexibility as to when the schemas and user-provided values are set.

+ +

For example, you might need to set the values from different sources. Thanks to lazy processing we won’t actually validate the schema until you try to access a value. Because of this, you might not know there’s a validation issue until you attempt to read a value:

+ +
use League\Config\Configuration;
+use Nette\Schema\Expect;
+
+$config = new Configuration([
+    'debug_mode' => Expect::bool()->required(),
+    'database' => Expect::structure([
+        'driver' => Expect::anyOf('mysql', 'postgresql', 'sqlite')->required(),
+        'host' => Expect::string()->default('localhost'),
+        'port' => Expect::int()->min(1)->max(65535),
+        'ssl' => Expect::bool(),
+        'database' => Expect::string()->required(),
+        'username' => Expect::string()->required(),
+        'password' => Expect::string()->nullable(),
+    ]),
+    'logging' => Expect::structure([
+        'enabled' => Expect::bool()->default($_ENV['DEBUG'] == true),
+        'file' => Expect::string()->deprecated("use logging.path instead"),
+        'path' => Expect::string()->assert(function ($path) { return \is_writeable($path); })->required(),
+    ]),
+]);
+
+// Load configuration from a file.
+// For the sake of this example, let's assume the user didn't set 'debug_mode'.
+// Even though this is a required option, we don't validate the schema immediately so you can add it later.
+$config->merge(json_decode(file_get_contents('database.json'), true));
+
+if ($_ENV['APP_ENV'] === 'prod') {
+    $config->set('debug_mode', false);
+    $config->merge(json_decode(file_get_contents('config.prod.json'), true));
+}
+
+// This call below will throw an exception if "debug_mode" wasn't set at all
+if ($config->get('debug_mode')) {
+    // ...
+}
+
+ + +
+ +

+ Edit this page +

+
+ + +
+ + + + + + + + diff --git a/1.1/mutability/index.html b/1.1/mutability/index.html new file mode 100644 index 0000000..2ca27b7 --- /dev/null +++ b/1.1/mutability/index.html @@ -0,0 +1,238 @@ + + + + + + + + + + + + + + + + + Mutability - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + + + + + + + + +
+
+ + + + + + +

Mutability

+ +

Thanks to lazy processing, you can define schemas and set user-provided values at any time and in any order. This can be very convenient in many cases, but you might have times where you’d like to provide a read-only version of the Configuration to ensure nobody else can modify it.

+ +

Read-Only Reader

+ +

To do this, simply call $config->reader(). This will return an object that only has the get() and exists() methods, preventing others from further modifying the configuration:

+ +
use League\Config\Configuration;
+
+$config = new Configuration([/* ... */]);
+
+$someOtherObject->setConfig($config->reader());
+
+ +

Because both the reader and the main Configuration implement ConfigurationInterface, you can type-hint against that anywhere you need to retrieve values but not necessarily modify things.

+ + +
+ +

+ Edit this page +

+
+ + +
+ + + + + + + + diff --git a/1.1/philosophy/index.html b/1.1/philosophy/index.html new file mode 100644 index 0000000..e78767c --- /dev/null +++ b/1.1/philosophy/index.html @@ -0,0 +1,269 @@ + + + + + + + + + + + + + + + + + Philosophy - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + + + + + + + + +
+
+ + + + + + +

Philosophy

+ +

There are lots of great configuration libraries out there, each one serving a slightly different purpose. As a result, this library aims to satisfy a particular niche not being served well by others by taking a simple yet opinionated approach to configuration with the following goals:

+ +
    +
  • The configuration should operate on arrays with nested values which are easily accessible
  • +
  • The configuration structure should be defined with strict schemas defining the overall structure, allowed types, and allowed values
  • +
  • Schemas should be defined using a simple, fluent interface
  • +
  • You should be able to add and combine schemas but never modify existing ones
  • +
  • Both the configuration values and the schema should be defined and managed with PHP code
  • +
  • Schemas should be immutable; they should never change once they are set
  • +
  • Configuration values should never define or influence the schemas
  • +
+ +

As a result, this library will likely never support features like:

+ +
    +
  • Loading and/or exporting configuration values or schemas using YAML, XML, or other files +
      +
    • You can still implement this yourself, if needed
    • +
    +
  • +
  • Parsing configuration values from a command line or other user interface
  • +
  • Dynamically changing the schema, allowed values, or default values based on other configuration values
  • +
+ +

If you need that functionality you should check out other great libraries like:

+ + + +

Dependencies

+ +

To help facilitate this approach, we heavily rely on the following two open-source libraries under-the-hood:

+ + + +

These were chosen specifically for being minimal, well-written, and unlikely to conflict with other dependencies you might have installed.

+ + + +
+ +

+ Edit this page +

+
+ + +
+ + + + + + + + diff --git a/1.1/reading-values/index.html b/1.1/reading-values/index.html new file mode 100644 index 0000000..ad5a9e1 --- /dev/null +++ b/1.1/reading-values/index.html @@ -0,0 +1,267 @@ + + + + + + + + + + + + + + + + + Reading Validated Options - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + + + + + + + + +
+
+ + + + + + +

Reading Validated Options

+ +

Once the schema has been defined and the user options have been set you are ready to read them elsewhere in your application! Thanks to lazy processing, this library will apply the schemas and validations only if/when you attempt to read a value.

+ +

The processed, validated configuration options can be read using the get() method. Simply pass in the name of the option you wish to fetch:

+ +
use League\Config\Configuration;
+use Nette\Schema\Expect;
+
+$config = new Configuration([
+    'debug_mode' => Expect::bool()->required(),
+    'database' => Expect::structure([
+        'driver' => Expect::anyOf('mysql', 'postgresql', 'sqlite')->required(),
+        'host' => Expect::string()->default('localhost'),
+        'port' => Expect::int()->min(1)->max(65535),
+        'ssl' => Expect::bool(),
+        'database' => Expect::string()->required(),
+        'username' => Expect::string()->required(),
+        'password' => Expect::string()->nullable(),
+    ]),
+    'logging' => Expect::structure([
+        'enabled' => Expect::bool()->default($_ENV['DEBUG'] == true),
+        'file' => Expect::string()->deprecated("use logging.path instead"),
+        'path' => Expect::string()->assert(function ($path) { return \is_writeable($path); })->required(),
+    ]),
+]);
+
+// TODO: Set the configuration values
+$config->merge([/* ... */]);
+
+var_dump($config->get('debug_mode')); // a string
+var_dump($config->get('database'));   // an array
+
+ +

You can access nested options using “dot access” expressions like this:

+ +
var_dump($config->get('database.driver')); // a string
+
+// slashes can also be used instead of dots:
+var_dump($config->get('database/driver')); // a string
+
+ +

Undefined Options

+ +

If you attempt to get() an option that was not defined in the schema an exception will be thrown. This is probably not an issue in cases where you wrote the schema and know it should always contain certain options. But in some cases (perhaps you’re conditionally adding certain schemas) you might want to first check whether an option is defined before attempting to read it - you can do that with the exists() method. It takes the same arguments as get() but will return true or false based on whether that item exists.

+ + +
+ +

+ Edit this page +

+
+ + +
+ + + + + + + + diff --git a/1.1/schemas/index.html b/1.1/schemas/index.html new file mode 100644 index 0000000..e9a9f40 --- /dev/null +++ b/1.1/schemas/index.html @@ -0,0 +1,325 @@ + + + + + + + + + + + + + + + + + Schemas - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + + + + + + + + +
+
+ + + + + + +

Configuration Schemas

+ +

A “schema” defines the exact structure of arrays, keys, and values that users can configure. By using a schema, you can:

+ +
    +
  • Enforce that certain expected options are set by marking them required
  • +
  • Provide default values when none are provided by the user
  • +
  • Validate that values are certain types, numbers within ranges, match regular expressions, or contain specific sets of values (like enums)
  • +
  • Mark old options as deprecated
  • +
  • Cast values to certain types, including both scalars and custom objects
  • +
+ +

This library includes the nette/schema package to define and process the schemas. You use their Expect class to define the schemas, passing those into our library which handles all of the processing for you. You can find some example of that below, but we highly recommending reading their documentation for complete details on all the options available to you.

+ +

Example

+ +
use League\Config\Configuration;
+use Nette\Schema\Expect;
+
+// Define your configuration schema
+$config = new Configuration([
+    'debug_mode' => Expect::bool(),
+    'database' => Expect::structure([
+        'driver' => Expect::anyOf('mysql', 'postgresql', 'sqlite')->required(),
+        'host' => Expect::string()->default('localhost'),
+        'port' => Expect::int()->min(1)->max(65535),
+        'ssl' => Expect::bool(),
+        'database' => Expect::string()->required(),
+        'username' => Expect::string()->required(),
+        'password' => Expect::string()->nullable(),
+    ]),
+    'logging' => Expect::structure([
+        'enabled' => Expect::bool()->default($_ENV['DEBUG'] == true),
+        'file' => Expect::string()->deprecated("use logging.path instead"),
+        'path' => Expect::string()->assert(function ($path) { return \is_writeable($path); })->required(),
+    ]),
+]);
+
+ +

Tip: By default, nette/schema assumes that nested options (Expect::structure) will be cast to stdClass objects, but we automatically cast those to array instead, so don’t worry about doing that yourself.

+ +

Merging Schemas

+ +

You might have different systems or components that define their own schemas:

+ +
use Nette\Schema\Expect;use Nette\Schema\Schema;
+
+class DatabaseConnection
+{
+    public static function getSchema(): Schema
+    {
+        return Expect::structure([
+            'driver' => Expect::anyOf('mysql', 'postgresql', 'sqlite')->required(),
+            'host' => Expect::string()->default('localhost'),
+            'port' => Expect::int()->min(1)->max(65535),
+            'ssl' => Expect::bool(),
+            'database' => Expect::string()->required(),
+            'username' => Expect::string()->required(),
+            'password' => Expect::string()->nullable(),
+        ]);
+    }
+}
+
+class Logger
+{
+    public static function getSchema(): Schema
+    {
+        return Expect::structure([
+            'enabled' => Expect::bool()->default($_ENV['DEBUG'] == true),
+            'file' => Expect::string()->deprecated("use logging.path instead"),
+            'path' => Expect::string()->assert(function ($path) { return \is_writeable($path); })->required(),
+        ]);
+    }
+}
+
+ +

You can combine these into a single Configuration using the constructor and/or the addSchema() method. All three examples in the snippet below will achieve the same result:

+ +
use League\Config\Configuration;
+
+$config = new Configuration([
+    'database' => DatabaseConnection::getSchema(),
+    'logging' => Logger::getSchema(),
+]);
+
+// or
+
+$config = new Configuration([
+    'database' => DatabaseConnection::getSchema(),
+]);
+
+$config->addSchema('logging', Logger::getSchema());
+
+// or
+
+$config = new Configuration();
+$config->addSchema('database', DatabaseConnection::getSchema());
+$config->addSchema('logging', Logger::getSchema());
+
+ +

Schema Types

+ +

See the nette/schema documentation for full details on the different Expect options you can use to define different types of schemas.

+ + +
+ +

+ Edit this page +

+
+ + +
+ + + + + + + + diff --git a/1.1/setting-values/index.html b/1.1/setting-values/index.html new file mode 100644 index 0000000..2ad1837 --- /dev/null +++ b/1.1/setting-values/index.html @@ -0,0 +1,291 @@ + + + + + + + + + + + + + + + + + Setting User-Provided Values - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + + + + + + + + +
+
+ + + + + + +

Setting User-Provided Values

+ +

Once your schema has been defined you can apply user-provided configuration values. There are two methods available to do this:

+ +
    +
  • set($key, $value) - Define a single value
  • +
  • merge($values) - Define multiple values in one call
  • +
+ +

Example

+ +

Let’s take the following configuration as an example:

+ +
use League\Config\Configuration;
+use Nette\Schema\Expect;
+
+$config = new Configuration([
+    'debug_mode' => Expect::bool()->required(),
+    'database' => Expect::structure([
+        'driver' => Expect::anyOf('mysql', 'postgresql', 'sqlite')->required(),
+        'host' => Expect::string()->default('localhost'),
+        'port' => Expect::int()->min(1)->max(65535),
+        'ssl' => Expect::bool(),
+        'database' => Expect::string()->required(),
+        'username' => Expect::string()->required(),
+        'password' => Expect::string()->nullable(),
+    ]),
+    'logging' => Expect::structure([
+        'enabled' => Expect::bool()->default($_ENV['DEBUG'] == true),
+        'file' => Expect::string()->deprecated("use logging.path instead"),
+        'path' => Expect::string()->assert(function ($path) { return \is_writeable($path); })->required(),
+    ]),
+]);
+
+ +

You could set everything at once like this:

+ +
$config->merge([
+    'debug_mode' => false,
+    'database' => [
+        'driver' => 'mysql',
+        'port' => 3306,
+        'database' => 'myapp',
+        'username' => 'myapp_user',
+        'password' => 'hunter2',
+    ],
+    'logging' => [
+        'enabled' => true,
+        'file' => '/var/log/myapp.log',
+    ],
+]);
+
+ +

Maybe that array of data comes from a different file or method:

+ +
$config->merge(getUserConfig());
+
+// or
+
+$config->merge(json_decode(file_get_contents('database.json'), true));
+
+ +

Options can also be set individually, if needed:

+ +
// Load config from a json file...
+$config->merge(json_decode(file_get_contents('database.json'), true));
+// But override a certain setting
+$config->set('debug_mode', false);
+
+ + +
+ +

+ Edit this page +

+
+ + +
+ + + + + + + + diff --git a/1.1/upgrading/index.html b/1.1/upgrading/index.html new file mode 100644 index 0000000..637a096 --- /dev/null +++ b/1.1/upgrading/index.html @@ -0,0 +1,231 @@ + + + + + + + + + + + + + + + + + Upgrading from 1.0 - 1.1 - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + + + + + + + + +
+
+ + + + + + +

Upgrading from 1.0 to 1.1

+ +

Minimum PHP version

+ +

The minimum PHP version has changed to 7.4+ or 8.0+.

+ +

Minimum nette/schema version

+ +

The minimum version of the nette/schema library has been bumped to 1.2.0+.

+ + +
+ +

+ Edit this page +

+
+ + +
+ + + + + + + + diff --git a/CNAME b/CNAME new file mode 100644 index 0000000..e5b3eeb --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +config.thephpleague.com diff --git a/README.md b/README.md new file mode 100644 index 0000000..9b7795d --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ + +# Don't commit to this branch! + + +This branch is automatically generated by Jekyll via GitHub Actions. + +To make changes, please go back to the `main` branch and make changes within the `docs` folder. diff --git a/changelog/index.html b/changelog/index.html new file mode 100644 index 0000000..ffce33c --- /dev/null +++ b/changelog/index.html @@ -0,0 +1,50 @@ + + + + + + + + + league/config - Simple yet expressive configuration library for PHP apps + + + + + + + + + + +
+
+

Config

+

Simple yet expressive configuration library for PHP apps

+

$ composer require league/config

+
+
+ +
+
+
+

Redirecting…

+
+ Click here if you are not redirected. + +
+
+
+
+ + + + diff --git a/custom.css b/custom.css new file mode 100644 index 0000000..c44a81c --- /dev/null +++ b/custom.css @@ -0,0 +1,430 @@ +html { + background:#f2f7fc; +} + +body { + min-width: 320px; + display: flex; + flex-flow: column; +} + +blockquote { + border-left: 4px solid #ccc; + font-style:italic; + box-sizing: border-box; + padding:0 10px; +} + +header { + position:fixed; + height:4.5em; + z-index: 1; + border-bottom:1px solid #cfe4f9; + max-width: none; + width: 100%; + padding:0; + margin:0; + background:#fff; +} + +header .header-content:after { + content: ""; + display: table; + clear: both; +} + +header .title { + float: left; + text-align:left; + font-family: "Museo 100", sans-serif; + font-weight: bold; + margin:0; + padding:0; + width:400px; +} + +header .title a { + color:#ff4143; + text-decoration: none; +} + +header .search { + float:left; + text-align:right; + width:calc(100% - 480px); + padding-right:.3em; +} + +.banner { + max-width: 100%; +} + +#doc-search { + font-family: "Museo Sans 500", sans-serif; + font-weight: normal; + font-size: 16px; + border:1px solid #e8e8e8; + background-color:#f4f4f4; + padding:.5em 1em; + margin-left:.3em; + border-radius: .3em; +} + +header .versions { + float:left; + display:none; + font-family: "Museo Sans 500", sans-serif; + font-weight: normal; +} + +header .versions h2 { + font-family: "Museo Sans 500", sans-serif; + font-weight: normal; + font-size: 16px; + background:#1672ce; + color:#fff; + margin:0; + width: 75px; + text-align: center; + border-radius: .3em; + margin-bottom:.4em; + padding:.5em .3em; + cursor: pointer; + transition: 0.3s; +} + +header .versions h2:hover { + background: #0a64bf; +} + +header .versions ul { + display:none; + margin:0; + padding:0; + list-style:none; + width: 75px; +} + +header .versions .show { + display:block; +} + +header .versions li { + margin:0; + padding:0; + text-align: center; +} + +header .versions a { + display:block; + margin:0; + padding:.5em .3em; + text-decoration:none; + color:#1672ce; + background: #fff; + border:solid #c7c7c7; + border-width:0 1px 1px; +} + +header .versions a:hover { + background:#f1f1f1; +} + +header .versions li:first-of-type a { + border-top-width: 1px; + border-radius:.3em .3em 0 0; +} + +header .versions li:last-of-type a { + border-radius:0 0 .3em .3em; +} + +label[for=menu] { + position:fixed; + z-index: 2; + top:20px; + right:0; + display:inline-block; + box-sizing: border-box; + background:transparent; + color:#1672ce; + width:50px; + font-size:30px; + line-height: 1; + padding:0; + margin:0; +} + +label[for=menu]:hover { + background:transparent; + color:#1672ce; +} + +main { + padding-top:4em; + background:none; +} + +/* ---------- header automatic permalink -----------*/ + +.header-permalink { + text-decoration: none; + color:transparent; + font-size:.8em; + vertical-align: super; +} + +.header-permalink:hover, +h1:hover .header-permalink, +h2:hover .header-permalink, +h3:hover .header-permalink, +h4:hover .header-permalink, +h5:hover .header-permalink { + text-decoration: none; + color:#777; +} + +h4 { + font-variant: small-caps; + font-size:1em; +} + +main article p { + max-width: 840px; +} + +main article a { + color:#1672ce; +} + +main article p code, +main article li code, +main article div > code { + font-family: Consolas,Monaco,'Andale Mono',monospace; + font-size: 17px; + line-height: 100%; + color:#1672ce; + background: #fff; + border:none; +} + +main article p img { + box-sizing: border-box; + margin:.3em; + padding:0; + display: block; +} + +main article p a img { + box-sizing: border-box; + margin:0; + padding:0; + display:inline; +} + +main article hr { + border: 1px solid #d9e0e6; +} + +footer { + border-top:1px solid #cfe4f9; + background:#fff; + max-width: none; + text-align:center; + color:#a1a1a1; +} + +footer span a { + color:#007ec6; +} + +main menu .menu-section { + border-bottom:1px dashed #cfe4f9; + padding-bottom:1em; +} + +main menu .menu-section:last-of-type { + border-bottom:none; +} + +main menu h2 { + margin-top:1.5em; + padding-left:.7em; + color:#2b3d50; + font-size:1em; + font-weight: bold; + text-transform: none; + box-shadow: none; +} + +main menu ul li a { + border-radius:.1em; + font-size:1em; + margin:.2em; + padding:.6em; + color:#1672ce; +} + +main menu ul li a:hover { + color:#1672ce; + padding:.6em; + background:transparent; + text-decoration: underline; +} + +main menu ul li.selected { + background: none; +} + +main menu ul li.selected a { + color:#fff; + background:#1672ce; + padding:.6em; +} + +main menu ul li.selected a:hover { + text-decoration: none; +} + +pre { + border-width:0 0 0 4px; + background: #fff; + width: fit-content; + max-width: 100%; +} + +main article table { + width: initial; + max-width: 100%; +} + +table { + border:1px solid #eee; + background: #fff; + box-shadow:0 6px 6px 0 rgba(80, 88, 94, .24); +} + +table th, +table th > * { + color:#fff; + background: #1672ce; +} + +@media screen and (max-width: 420px) { + table { + display: flex; + flex-direction: column; + justify-content: space-between; + font-size: 0.9rem; + } +} + +@media screen and (max-width: 375px) { + main article table td { + padding: 2px 5px 2px 2px; + } + thead tr { + font-size: 0.8rem; + } +} + +header .logo .name { + font-size: 1.6rem; + line-height: 100%; + margin: 0 !important; +} + +@media screen and (min-width: 768px) { + header .logo .name { + font-size: 2.5rem; + } +} + +@media screen and (min-width: 1024px) { + header .logo .name { + font-size: 3rem; + } +} + +header .logo em { + color: #777; + font-style: normal; +} + +@media screen and (max-width: 549px) { + header { + padding: 25px 0 20px 10px; + } + + menu { + text-align: center; + } + + header .logo { + text-align: left; + } +} + +@media screen and (min-width: 550px) { + header { + background:#fff; + } + + header .header-content { + box-sizing: border-box; + padding:1em; + } + + header .versions { + display: block; + } + + label[for=menu] { + display:none; + } + + main { + background: none; + } + + main menu { + border-right: 1px dashed #cfe4f9; + } + + main menu .versions-small { + display:none; + } + + main article p, + main article li { + font-size:.9em; + } +} + +@media screen and (max-width: 750px) { + #doc-search { + display: none; + } +} + +@media screen and (min-width: 850px) { + main article { + max-width: none; + } +} + +h2 code { + font-size: 0.8em; +} + +.features ul { + list-style-type: none; +} + +:target:before { + content: ' '; + display: block; + padding-top: 100px; + margin-top: -100px; + visibility: hidden; +} diff --git a/custom.js b/custom.js new file mode 100644 index 0000000..a84d855 --- /dev/null +++ b/custom.js @@ -0,0 +1,18 @@ +(() => { + + const uri = new URL(location.href); + + document.querySelector('header nav h2').addEventListener('click', function () { + this.parentNode.querySelector('ul').classList.toggle('show'); + }, false); + + document.querySelectorAll("main h2[id]").forEach((header) => { + uri.hash = header.id; + let link = document.createElement("a"); + link.className = "header-permalink"; + link.title = "Permalink"; + link.href = uri.toString(); + link.innerHTML = "¶"; + header.appendChild(link); + }); +})(); \ No newline at end of file diff --git a/global.css b/global.css new file mode 100644 index 0000000..984a501 --- /dev/null +++ b/global.css @@ -0,0 +1,42 @@ +.btn { + padding: .5rem 1rem; + margin-right: .25rem; + text-align: center; + border-radius: .25rem; + color: inherit; + text-decoration: inherit; + transition: 0.3s; +} + +.btn-block { + display: block; + width: auto; +} + +.btn-sm { + padding: .3rem .6rem; + font-size: .8rem; +} + +.btn-black { + background-color: #222222; + color: #ffffff; +} +.btn-black:hover { + background-color: #333; + color: #ffffff; +} + +.btn-pink { + background-color: #d53f8c; +} +.btn-pink:hover { + background-color: #d62b83; +} + +.btn-green { + background-color: #38a169; +} +.btn-green:hover { + background-color: #28a160; +} diff --git a/homepage.css b/homepage.css new file mode 100644 index 0000000..8e32775 --- /dev/null +++ b/homepage.css @@ -0,0 +1,380 @@ +blockquote { + border-left: 4px solid #ccc; + font-style:italic; + box-sizing: border-box; + padding:0 10px; +} + +footer { + text-align: center; + color:#fff; +} + +pre { + border-width:0 0 0 4px; + background: #fff; +} + +main p code, +main li code, +main div > code { + font-family: Consolas,Monaco,'Andale Mono',monospace; + font-size: 17px; + line-height: 100%; + color:#1672ce; + background: #fff; + border:none; +} +/* -------- homepage css -----------------*/ + +.homepage header { + margin:0 auto; + padding:0 0 3em; + box-sizing: border-box; + background:#19242F url(//thephpleague.com/img/header_bg.png) no-repeat top center; + background-size: cover; + max-width: none; + color:#fff; + font-family: "Museo 300", sans-serif; +} + +.homepage header h1 { + margin:.3em auto; + font-family: "Museo 300", sans-serif; + line-height: 250%; + font-weight: normal; +} + +.homepage header h2 { + margin:0 auto; + font-family: "Museo 300", sans-serif; + color:#ff4043; + font-size:36px; + line-height:1.33; + font-weight:normal; +} + +.homepage .badge-list { + background: #fff; + padding: 3em 0 0 0; + text-align: center; +} + +.homepage .composer span { + padding:.3em 1em; + background-color:rgba(0, 0, 0, .3); + color:#fff; + font-size:.9rem; + font-family: Consolas, Monaco ,'Andale Mono', monospace; + line-height: 140%; + text-align: left; + white-space: pre; + word-wrap: normal; + word-spacing: normal; + hyphens: none; + display:inline-block; + border-radius: .3em; +} + +.homepage .hot-links { + margin:0 auto; + padding:0; + list-style:none; + width:300px; + display:flex; + align-content: top; + align-items: center; +} + +.homepage .hot-links li { + padding:0; + margin:0; +} + +.homepage .hot-links a { + display:block; + margin:0; + padding:1em; + width:150px; + border-radius:2px 0 0 2px; + text-decoration:none; + text-align:center; + font-weight:bold; + background:#fff; + color:#ff4043; +} + +.homepage .hot-links :last-child a { + border-radius:0 2px 2px 0; + background:#ff4043; + color:#fff; +} + +.homepage .hot-links:hover :last-child a { + color:#ff4043; +} + +.homepage .hot-links:hover a { + background:#fff; + color:#ff4043; +} + +.homepage .hot-links:hover a:hover { + background: #ff4043; + color: #fff; +} + +.homepage main { + color: #2b3d50; + font-family: "Museo 300", sans-serif; + line-height: 160%; + font-weight: normal; + background:#19242f; + width:auto; + right:auto; +} + +.homepage main > div { + margin:0 auto; + padding:3em 0; + box-sizing: border-box; +} + +.inner-content { + margin:0 auto; + padding:1em; + box-sizing: border-box; + text-align:center; +} + +.inner-content h1 { + color:#fff; + font-size:50px; + line-height:100%; + font-weight:normal; + font-family:"Museo Sans 300", sans-serif; + text-transform:uppercase; + margin:0; +} + +.inner-content:after { + content: ''; + display:table; + clear:both; +} + +.projects, +.sponsors { + color: #fff; +} + +.projects h2, +.sponsors h2 { + font-size:50px; + line-height:100%; + font-weight:normal; + font-family:"Museo Sans 300", sans-serif; + text-transform:uppercase; + margin: 0 0 1em 0; +} + +.project-logos { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: center; +} + +.project-logos a { + display: block; + object-fit: contain; + margin: 0 16px; +} + +.project-logos img { + height: 70px; + max-width: 180px; +} + +.sponsors a { + color: #3399ff; +} +.sponsors ul { + list-style: none; + font-size: 1.1em; +} + +.features { + background: #F2F7FC; + border-bottom:1px solid #CFE4F9; + color:#666; + line-height: 1.5; + font-weight: normal; + font-variant: normal; + font-style: normal; + font-size: 18px; + font-family: "Museo 300", sans-serif; +} + +.features h1 { + color:#6abcdd; +} + +.features h2 { + color:#6abcdd; + font-weight: normal; +} + +.features p { + text-align: center; +} + +.features a { + color:#6abcdd; +} + +.highlights { + background:#fff; + border-bottom:1px solid #CFE4F9; +} + +.highlights .description { + color:#666; + line-height: 1.5; + font-weight: normal; + font-variant: normal; + font-style: normal; + font-size: 18px; + font-family: "Museo 300", sans-serif; + text-align: left; +} + +.highlights h1 { + color:#ff4043; + font-size: 36px; + line-height:115%; +} + +.highlights ol { + margin:0; + text-align:left; +} + +.highlights li { + margin:0 0 15px 0; + color:#666; + font-size:16px; + font-weight:bold; +} + +.highlights li p { + margin:0; + line-height: 1.4; + font-weight: normal; + font-variant: normal; + font-style: normal; + font-size: 18px; + font-family: "Museo 300", sans-serif; + color:#ff4043; +} + +.highlights a { + color:#ff4043; +} + +.questions { + padding:0; + background:#fff; + color:#666; + border-bottom:1px solid #CFE4F9; +} + +.questions h1 { + font-size:36px; + color:#ff4043; +} + +.questions a { + color:#6abcdd; +} + +.questions a:hover { + text-decoration: none; +} + +@media screen and (max-width: 549px) { + .homepage header h1 { + font-size:48px; + } + + .homepage .composer span { + font-size:1rem; + } +} + +@media screen and (min-width: 549px) { + .homepage header h1 { + margin:0 auto; + font-size:54px; + } + + .inner-content { + max-width:1000px; + } + + .homepage main { + width:initial; + right:initial; + } + + .highlights h1 { + font-size: 50px; + } + + .highlights li { + font-size:24px; + } + + .highlights li p { + font-size:20px; + } + + .highlights .column { + float:left; + width:45%; + } + + .highlights .one { + margin:0 10% 0 0; + } + + .documentation h1 { + font-size:50px; + } +} + +@media screen and (min-width:700px) { + .documentation .version { + float:left; + width:42%; + margin:2%; + max-width:289px; + } +} + +@media screen and (min-width: 910px) { + .documentation .version { + float:left; + width:30%; + margin:1%; + } + + .homepage header h1 { + margin:0 auto; + font-size:96px; + } +} + +#sponsors + p + ul { + list-style-type: none; +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..668a8c9 --- /dev/null +++ b/index.html @@ -0,0 +1,193 @@ + + + + + + + + + + league/config - Simple yet expressive configuration library for PHP apps + + + + + + + + + + + + + + + + + + +
+
+

Config

+

Simple yet expressive configuration library for PHP apps

+

$ composer require league/config

+ +

+
+
+ +
+
+ Author + Latest Version + Total Downloads + Software License + Build Status + Coverage Status + Quality Score +
+
+
+
+

Highlights

+
+

league/config helps you define configuration arrays with strict schemas and easy access to values with dot notation.

+
+
+
+
    + +
  1. Easy-to-use, expressive API

  2. + +
  3. Supports configuration schemas, allowed types, validation, deprecation, and more

  4. + +
  5. Simplified access to nested configuration options using `parent.child` syntax

  6. + +
  7. Define everything with code - no XML, YAML, or JSON required

  8. + +
+
+
+
+ +
+
+ + + + +

Features

+ +

Expressive, Fluent API

+ +
use League\Config\Configuration;
+use Nette\Schema\Expect;
+
+$config = new Configuration([
+    'database' => Expect::structure([
+        'driver' => Expect::anyOf('mysql', 'postgresql', 'sqlite')->required(),
+        'host' => Expect::string()->default('localhost'),
+        'port' => Expect::int()->min(1)->max(65535),
+        'database' => Expect::string()->required(),
+        'username' => Expect::string()->required(),
+        'password' => Expect::string()->nullable(),
+    ]),
+]);
+
+ +

Easily Access Nested Values

+ +
echo $config->get('database.driver');
+
+// or using slashes, if you prefer that syntax:
+echo $config->get('database/driver');
+
+ +

Set Options Individually Or Together

+ +
use League\Config\Configuration;
+
+$config = new Configuration([/*...*/]);
+
+$config->merge([
+    'database' => [
+        'driver' => 'mysql',
+        'port' => 3306,
+        'host' => 'localhost',
+        'database' => 'myapp',
+        'username' => 'myappdotcom',
+        'password' => 'hunter2',
+    ],
+]);
+
+if ($_ENV['APP_ENV'] === 'prod') {
+    $config->set('payment_gateway.test_mode', false);
+}
+
+ +

Combine Multiple Schemas Into One

+ +
use League\Config\Configuration;
+
+$config = new Configuration();
+$config->addSchema('database', DB::getConfigSchema());
+$config->addSchema('logging', Logger::getConfigSchema());
+$config->addSchema('mailer', Mailer::getConfigSchema());
+
+ +
+
+ +
+
+

Questions?

+

Config was created by Colin O'Dell. Find him on Twitter at @colinodell.

+
+
+ + +
+ + + + + + diff --git a/redirects.json b/redirects.json new file mode 100644 index 0000000..1b740ff --- /dev/null +++ b/redirects.json @@ -0,0 +1 @@ +{"/changelog/":"http://config.thephpleague.com/releases/","/upgrading/":"http://config.thephpleague.com/1.1/upgrading/"} \ No newline at end of file diff --git a/releases/index.html b/releases/index.html new file mode 100644 index 0000000..cac6c6d --- /dev/null +++ b/releases/index.html @@ -0,0 +1,214 @@ + + + + + + + + + + + + + + + + + Release Notes - league/config + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +

+ + +
+
+ + + + +
+ +
+

Versions

+ +
+ + + +

Upgrading Guide

+ + + +
+
+ + + + + + +

Release Notes

+ +

v1.2.0 - 2022-12-11

+ +

Changed

+ +
    +
  • Values can now be set prior to the corresponding schema being registered.
  • +
  • exists() and get() now only trigger validation for the relevant schema, not the entire config at once.
  • +
+ +

v1.1.1 - 2021-08-14

+ +

Changed

+ +
    +
  • Bumped the minimum version of dflydev/dot-access-data for PHP 8.1 support (#3)
  • +
+ +

v1.1.0 - 2021-06-19

+ +

Changed

+ +
    +
  • Bumped the minimum PHP version to 7.4+
  • +
  • Bumped the minimum version of nette/schema to 1.2.0
  • +
+ +

v1.0.1 - 2021-05-31

+ +

Fixed

+ +
    +
  • Fixed the ConfigurationExceptionInterface marker interface not extending Throwable (#2)
  • +
+ +

v1.0.0 - 2021-05-31

+ +

Initial release! :tada:

+ + + +
+ +

+ Edit this page +

+
+ + +
+ + + + + + + + diff --git a/support.css b/support.css new file mode 100644 index 0000000..d9b6321 --- /dev/null +++ b/support.css @@ -0,0 +1,112 @@ +.support-banner-wrapper { + position: fixed; + bottom: 0; + left: 0; + right: 0; + margin: 1rem; +} + +.support-banner { + color: #fff; + background-color: #000; + box-shadow: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05); + border-radius: 0.5rem; + + padding: 0.5rem 1rem; + margin: 0 auto; + width: 100%; + + justify-content: space-between; + -webkit-box-pack: justify; + + align-items: center; + -webkit-box-align: center; + + display: flex; + flex-wrap: wrap; + flex-direction: row; + -webkit-box-orient: horizontal; + -webkit-box-direction: normal; + + z-index: 100; +} + +@media screen and (min-width: 1200px) { + .support-banner { + max-width: 1192px; + } +} + +.support-banner-left { + width: 0; + margin: 0; + + flex: 1 1 0%; + -webkit-box-flex: 1; +} + +.support-banner-right { + display: flex; + flex-shrink: 0; + width: auto; + margin-top: 0; + + order: 2; + -webkit-box-ordinal-group: 3; + + justify-content: space-between; + -webkit-box-pack: justify; + + align-items: center; + -webkit-box-align: center; +} + +.support-banner-close { + width: 1.5rem; + margin: 0 0 0 0.5rem; + font-size: .875rem; + height: 1.5rem; + + border: none; + border-radius: 9999px; + padding: 0; + line-height: inherit; + color: inherit; + cursor: pointer; + background-color: transparent; + background-image: none; + -webkit-appearance: button; + + overflow: visible; + text-transform: none; + + display: flex; + + justify-content: center; + -webkit-box-pack: center; + + align-items: center; + -webkit-box-align: center; + + order: 3; + -webkit-box-ordinal-group: 4; +} + +.hidden { + display: none; +} + +@media (min-width: 700px) { + .sm\:inline-block { + display: inline-block; + } +} + +@media (min-width: 1060px) { + .lg\:hidden { + display: none; + } + .lg\:inline-block { + display: inline-block; + } +} diff --git a/upgrading/index.html b/upgrading/index.html new file mode 100644 index 0000000..20d61de --- /dev/null +++ b/upgrading/index.html @@ -0,0 +1,50 @@ + + + + + + + + + league/config - Simple yet expressive configuration library for PHP apps + + + + + + + + + + +
+
+

Config

+

Simple yet expressive configuration library for PHP apps

+

$ composer require league/config

+
+
+ +
+
+
+

Redirecting…

+
+ Click here if you are not redirected. + +
+
+
+
+ + + +