Drupal - How can I read Yaml files?

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'));

You can use the Symfony component as well in Drupal 8:

use Symfony\Component\Yaml\Yaml;    

$file_path = DRUPAL_ROOT . '/core/modules/toolbar/toolbar.breakpoints.yml';
$file_contents = file_get_contents($file_path);
$ymldata = Yaml::parse($file_contents);

Tags:

8