Documentation / YAML
Readers for YAML input.
The YamlReader
$reader = new YamlReader();
// Read from YAML string
$configuration = $reader->createConfiguration('a: 1');
Constructor options
public function __construct(
string $class = Configuration::class,
);
class
- An instance of any class implementingConfigurationInterface
to be returned (defaultConfiguration
).
createConfiguration options
public function createConfiguration(
string $yaml = '{}',
): ConfigurationInterface;
yaml
- YAML string to parse.
The YamlFileReader
$reader = new YamlFileReader();
// Read from file
$configuration = $reader->createConfiguration(path: 'path/to/file.yaml');
Constructor options
public function __construct(
string $class = Configuration::class,
string $prefix = '',
bool $optional = false,
);
class
- An instance of any class implementingConfigurationInterface
to be returned (defaultConfiguration
).prefix
- File path prefix.optional
- If true, reader will return empty configuration if file is missing.
createConfiguration options
public function createConfiguration(
string $path = 'config.yaml',
): ConfigurationInterface;
path
- File to be read.