Download the PHP package utopia-php/config without Composer
On this page you can find all versions of the php package utopia-php/config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package config
Utopia Config
[!IMPORTANT] This repository is a read-only mirror of
packages/configin appwrite/appwrite. Development happens there — please open issues and pull requests against appwrite/appwrite.
Utopia Config library is simple and lite library for managing application configuration. This library is aiming to be as simple and easy to learn and use. This library is maintained by the Appwrite team.
Although this library is part of the Utopia Framework project it is dependency free and can be used as standalone with any other PHP project or framework.
Getting started
Install using Composer:
For above example to work, make sure to setup config.json file too:
Notice dot notation is supported, and automatically finds nested objects.
Alternatively, you can load configs directly from a variable:
Below is example how to combine multiple configs into one:
You can also load environment variables instead of reading dotenv file:
Schema rules
Config::load() throws Load when the schema or the data cannot produce a complete object:
- Every property must be public, typed, and carry a
#[Key]or#[ConfigKey]attribute, and the class must declare no methods. - A required key that is absent is an error.
- An optional key (
required: false) that is absent keeps the property's default. Without a default, a nullable property becomesnull, and any other property is an error rather than being left uninitialised.
Parser\PHP includes the contents, so they must start with <?php. Anything before the tag would be printed, so it is rejected with Parse instead.
Registry
Config also holds a process-wide key/value registry, for configuration an application assembles at boot and reads everywhere:
A key that is absent or null returns the default.
System requirements
Utopia Framework requires PHP 8.0 or later. We recommend using the latest PHP version whenever possible.
When using YAML adapter, or running tests with it, you need to install the YAML extension for PHP.
Copyright and license
The MIT License (MIT) http://www.opensource.org/licenses/mit-license.php