How can I read Yaml files? I have been trying to figure out how to decode ( also try to encode) my YML file so I can have full control over on PHP array. I try this...



And as you can see, I did not get the information inside of the YML file.

My question is what I'm doing wrong ? Why is not showing me the information inside of /core/modules/toolbar/toolbar.breakpoints.yml file?

Here is code snippet...

use Drupal\Component\Serialization\Yaml;

$breakpointEncoded = Yaml::encode('/core/modules/toolbar/toolbar.breakpoints.yml');
var_dump($breakpointEncoded);
The arg to decode is:


  The raw data string to decode


So you need (e.g.):

$breakpointEncoded = Yaml::decode(file_get_contents('/PATH/TO/core/modules/toolbar/toolbar.breakpoints.yml'));