Please consider following Yaml file:
files:
/etc/cron.d/{templateJob}:
group: root
mode: "000644"
owner: root
content: |
{templateJobTime} root /usr/local/bin/{templateJob}.sh
/usr/local/bin/{templateJob}.sh:
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
date > /tmp/date
curl -s {templateJobURL}
exit 0
commands:
remove_old_cron:
command: "rm -f /etc/cron.d/*.bak"
I want to parse and dump the above file using \Symfony\Component\Yaml\Yaml after some modifications, currently, I'm getting the following output:
//input
$content = Yaml::parse(file_get_contents('file.config'));
//modifications
//output
file_put_contents('file.config',Yaml::dump($content, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
#Output
files:
'/etc/cron.d/{templateJob}':
group: root
mode: '000644'
owner: root
content: "{templateJobTime} root /usr/local/bin/{templateJobFile}.sh\n"
'/usr/local/bin/{testJobFile}.sh':
mode: '000755'
owner: root
group: root
content: "#!/bin/bash\ndate > /tmp/date\ncurl -s {templateJobURL}\nexit 0\n"
commands:
remove_old_cron:
command: 'rm -f /etc/cron.d/*.bak'
see the difference between input and output file, how can I get the correct output in input file format.