承接 divineomega/php-hcl-parser 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

divineomega/php-hcl-parser

最新稳定版本:v2.0.0

Composer 安装命令:

composer require divineomega/php-hcl-parser

包简介

PHP HCL Parser

README 文档

README

Build Status Coverage Status StyleCI

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

This library parses HCL configuration files into PHP objects.

Installation

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

composer require jord-jd/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.

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

The resulting object will look similar to the following.

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"
            }
          }
        }
      }
    }
  }
}

统计信息

  • 总下载量: 18.55k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 14
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 14
  • Watchers: 0
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0-only
  • 更新时间: 2018-04-10