2017 © Pedro Peláez
 

library yaml_comments

YAML parser that also reads/writes comment lines

image

klausi/yaml_comments

YAML parser that also reads/writes comment lines

  • Sunday, March 19, 2017
  • by klausi
  • Repository
  • 3 Watchers
  • 4 Stars
  • 165 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 2 Open issues
  • 2 Versions
  • 1 % Grown

The README.md

YamlComments

Parses YAML and provides comments with their line numbers as well as the line number of any given key of the document structure., (*1)

The parser was copied and modified from the Symfony YAML component, MIT license Copyright (c) 2004-2017 Fabien Potencier, (*2)

Usage

use Klausi\YamlComments\YamlComments;

$exampleYaml = <<<'EOF'
name: Node
type: module
# Messing up line numbers with comments, yay!
description: 'Allows content to be submitted to the site and displayed on pages.'
package: Core
version: VERSION
core: 8.x
configure: entity.node_type.collection
dependencies:
  - text
  - drupal:rest
  - views
  # Some comment here.
  - rules
EOF;

$parseResult = YamlComments::parse($exampleYaml);

Get the comment lines of this document:, (*3)

print_r($parseResult->getComments());

``` Array ( [3] => # Messing up line numbers with comments, yay! [13] => # Some comment here. ), (*4)


Get the line number of a particular key: ```php print $parseResult->getLineNumber('name'); 1 print $parseResult->getLineNumber('description'); 4 print $parseResult->getLineNumber(['dependencies', 3]); 14

The Versions

19/03 2017

0.x-dev

0.9999999.9999999.9999999-dev https://github.com/klausi/yaml_comments

YAML parser that also reads/writes comment lines

  Sources   Download

GPLv2+

The Requires

  • php >=5.5

 

The Development Requires

yaml

12/03 2017

dev-full-parser-clone

dev-full-parser-clone https://github.com/klausi/yaml_comments

YAML parser that also reads/writes comment lines

  Sources   Download

GPLv2+

The Requires

 

The Development Requires

yaml