Skip to content

scottasmith/node-yaml2php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yaml2php

Simple library to convert yaml configuration into PHP using yaml-ast-parser.

Installation

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm install yaml2php

Usage

Read from file:

import { fromFile } from 'yaml2php';

try {
  var php = fromFile('example.yml');
  console.log(php);
} catch (e) {
  console.log(e);
}

Read from string:

import { fromString } from 'yaml2php';

try {
  var php = fromString(`---
key1:
    - 1
    - 'Two'
    - false
`);

  console.log(php);
} catch (e) {
  console.log(e);
}

For both functions, there are two options as second and third parameters. These make the code more readable

function fromFile(filename: string, pretty?: boolean, indent?: number): string;
function fromString(value: string, pretty?: boolean, indent?: number): string;

About

Node.js libary to convert Yaml to PHP config

Resources

License

Stars

Watchers

Forks

Packages

No packages published