symfony/yaml library
- Add
symfony/yaml
library tocomposer.json
file:
"require": {
"symfony/yaml": "^5.0"
}
- Install library from the command line:
composer install
- Write data to YAML file:
<?php
use Symfony\Component\Yaml\Yaml;
require_once __DIR__ . '/vendor/autoload.php';
$data = [
'parameters' => [
'host' => 'localhost',
'port' => 8080,
'user' => 'root',
],
];
$yaml = Yaml::dump($data, indent: 2);
file_put_contents('test.yaml', $yaml);
Leave a Comment
Cancel reply