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