2017 © Pedro Peláez
 

library php-hcl-parser

PHP HCL Parser

image

divineomega/php-hcl-parser

PHP HCL Parser

  • Wednesday, July 4, 2018
  • by DivineOmega
  • Repository
  • 1 Watchers
  • 3 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 5 Versions
  • 13 % Grown

The README.md

⚒🔀🐘 PHP HCL Parser

Build Status Coverage Status StyleCI, (*1)

HCL is a configuration language make by HashiCorp. HCL files are used by several HashiCorp products, including Terraform., (*2)

This library parses HCL configuration files into PHP objects., (*3)

Installation

You can install the PHP HCL Parser library using Composer. Just run the following command from the root of your project., (*4)

composer require divineomega/php-hcl-parser

Usage

To parse HCL into a PHP object, create a new HCLParser object, passing it the HCL (as a string), then call the parse method. See the example below., (*5)

$hcl = file_get_contents('example.tf');
$configObject = (new HCLParser($hcl))->parse();

The resulting object will look similar to the following., (*6)

object(stdClass)#5 (2) {
  ["provider"]=>
  array(1) {
    [0]=>
    object(stdClass)#4 (1) {
      ["aws"]=>
      array(1) {
        [0]=>
        object(stdClass)#2 (3) {
          ["access_key"]=>
          string(17) "${var.access_key}"
          ["region"]=>
          string(13) "${var.region}"
          ["secret_key"]=>
          string(17) "${var.secret_key}"
        }
      }
    }
  }
  ["resource"]=>
  array(1) {
    [0]=>
    object(stdClass)#8 (1) {
      ["aws_instance"]=>
      array(1) {
        [0]=>
        object(stdClass)#7 (1) {
          ["example"]=>
          array(1) {
            [0]=>
            object(stdClass)#6 (2) {
              ["ami"]=>
              string(12) "ami-2757f631"
              ["instance_type"]=>
              string(8) "t2.micro"
            }
          }
        }
      }
    }
  }
}

The Versions

04/07 2018

dev-master

9999999-dev

PHP HCL Parser

  Sources   Download

LGPL-3.0-only

The Development Requires

by Jordan Hall

04/07 2018

v1.2.0

1.2.0.0

PHP HCL Parser

  Sources   Download

LGPL-3.0-only

The Development Requires

by Jordan Hall

14/06 2018

v1.1.0

1.1.0.0

PHP HCL Parser

  Sources   Download

LGPL-3.0-only

The Development Requires

by Jordan Hall

11/04 2018

v1.0.0

1.0.0.0

PHP HCL Parser

  Sources   Download

LGPL-3.0-only

The Development Requires

by Jordan Hall

11/04 2018

dev-analysis-861MGP

dev-analysis-861MGP

PHP HCL Parser

  Sources   Download

LGPL-3.0-only

The Development Requires

by Jordan Hall